[PR #7686] [CLOSED] fix(sso): use signingCert instead of encryptCert for SAML IdP #33094

Closed
opened 2026-04-17 23:45:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7686
Author: @theNailz
Created: 1/29/2026
Status: Closed

Base: mainHead: fix/saml-idp-signingcert


📝 Commits (2)

  • afae8e8 fix(sso): use signingCert instead of encryptCert for SAML IdP
  • e457c3e fix: respect configured idpMetadata.singleSignOnService

📊 Changes

1 file changed (+31 additions, -7 deletions)

View changed files

📝 packages/sso/src/routes/sso.ts (+31 -7)

📄 Description

Problem

The signInSSO endpoint incorrectly constructs the samlify IdentityProvider with encryptCert instead of signingCert, causing:

  • Azure AD (and other IdPs) to reject the SAML AuthnRequest with:
    AADSTS7500511: XML attribute 'AssertionConsumerServiceURL' in the SAML message must be a URI

Root Cause

In signInSSO, the IdentityProvider is constructed with:

  1. Wrong field name: encryptCert instead of signingCert - samlify ignores encryptCert for signing
  2. Missing fallback: entityID doesn't fall back to parsedSamlConfig.issuer
  3. Missing fallback: singleSignOnService doesn't fall back to parsedSamlConfig.entryPoint

The callback handlers (callbackSSOSAML, acsEndpoint) already implement this correctly.

Solution

Align the signInSSO implementation with the callback handlers by:

  1. Using signingCert instead of encryptCert
  2. Adding fallback to parsedSamlConfig.issuer for entityID
  3. Adding fallback to parsedSamlConfig.entryPoint for singleSignOnService
  4. Handling both metadata and non-metadata IdP configurations

Testing

  • Tested with Azure AD SAML SSO (Azure Entra ID)
  • SAML AuthnRequest now contains correct AssertionConsumerServiceURL and Issuer
  • SAML login flow completes successfully

Fixes #6609

🤖 Generated with Claude Code


Summary by cubic

Fixes SAML IdP construction in signInSSO so Azure AD and other IdPs accept AuthnRequests. Uses signingCert and correct fallbacks to restore the SSO login flow.

  • Bug Fixes
    • Use signingCert instead of encryptCert.
    • Fallback entityID to issuer.
    • Respect configured SingleSignOnService; fall back to entryPoint when missing.
    • Support both metadata XML and field-based IdP configs.

Written for commit e457c3e78a. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7686 **Author:** [@theNailz](https://github.com/theNailz) **Created:** 1/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/saml-idp-signingcert` --- ### 📝 Commits (2) - [`afae8e8`](https://github.com/better-auth/better-auth/commit/afae8e8f568b11485ade15503b794c3d44199280) fix(sso): use signingCert instead of encryptCert for SAML IdP - [`e457c3e`](https://github.com/better-auth/better-auth/commit/e457c3e78a002c7eeb0c6c140ca639592462af5f) fix: respect configured idpMetadata.singleSignOnService ### 📊 Changes **1 file changed** (+31 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/sso/src/routes/sso.ts` (+31 -7) </details> ### 📄 Description ## Problem The `signInSSO` endpoint incorrectly constructs the samlify `IdentityProvider` with `encryptCert` instead of `signingCert`, causing: - Azure AD (and other IdPs) to reject the SAML AuthnRequest with: `AADSTS7500511: XML attribute 'AssertionConsumerServiceURL' in the SAML message must be a URI` ## Root Cause In `signInSSO`, the `IdentityProvider` is constructed with: 1. Wrong field name: `encryptCert` instead of `signingCert` - samlify ignores `encryptCert` for signing 2. Missing fallback: `entityID` doesn't fall back to `parsedSamlConfig.issuer` 3. Missing fallback: `singleSignOnService` doesn't fall back to `parsedSamlConfig.entryPoint` The callback handlers (`callbackSSOSAML`, `acsEndpoint`) already implement this correctly. ## Solution Align the `signInSSO` implementation with the callback handlers by: 1. Using `signingCert` instead of `encryptCert` 2. Adding fallback to `parsedSamlConfig.issuer` for `entityID` 3. Adding fallback to `parsedSamlConfig.entryPoint` for `singleSignOnService` 4. Handling both metadata and non-metadata IdP configurations ## Testing - Tested with Azure AD SAML SSO (Azure Entra ID) - SAML AuthnRequest now contains correct `AssertionConsumerServiceURL` and `Issuer` - SAML login flow completes successfully Fixes #6609 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes SAML IdP construction in signInSSO so Azure AD and other IdPs accept AuthnRequests. Uses signingCert and correct fallbacks to restore the SSO login flow. - **Bug Fixes** - Use signingCert instead of encryptCert. - Fallback entityID to issuer. - Respect configured SingleSignOnService; fall back to entryPoint when missing. - Support both metadata XML and field-based IdP configs. <sup>Written for commit e457c3e78a002c7eeb0c6c140ca639592462af5f. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:45:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#33094