feat(plugin-auth): SAML 2.0 SSO via @better-auth/sso (ADR-0069 P3)#2404
Merged
Conversation
`@better-auth/sso@1.6.20` ships full SAML 2.0 (samlify-backed), so SAML needs no custom plugin — the same package that powers the OIDC trust list also exposes `/sso/saml2/sp/metadata`, `/sso/saml2/sp/acs/:providerId`, and registers SAML providers through the same `/sso/register` endpoint with a nested `samlConfig`. - `register_saml_provider` action on `sys_sso_provider` (Setup → SSO Providers) collecting flat IdP fields (providerId, IdP EntityID, domain, IdP SSO URL, IdP signing cert, NameID format). - `runRegisterSamlProviderFromForm` bridge (sibling of the OIDC one) reshapes the flat form into the nested `samlConfig`, derives the per-provider ACS URL (`/sso/saml2/sp/acs/<providerId>`), defaults the SP descriptor, and re-dispatches through `/sso/register` so the admin gate runs. Returns the SP ACS + metadata URLs. - ADR-0069 addendum corrects the stale "SAML is out of better-auth core" premise. Verified E2E against a test IdP: register → provider persisted with `saml_config`; SP metadata endpoint serves a valid `EntityDescriptor`/`SPSSODescriptor`; `/sign-in/sso` routes an email domain to the IdP with a valid `SAMLRequest` redirect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 11 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds SAML 2.0 SSO as the P3 deliverable of ADR-0069.
The key finding:
@better-auth/sso@1.6.20already ships full SAML 2.0 (samlify-backed) — the same package that powers the OIDC trust list. The ADR's original "SAML is out of better-auth core" premise is stale, so no custom plugin was needed. The package exposes/sso/saml2/sp/metadata,/sso/saml2/sp/acs/:providerId,/sso/saml2/sp/slo/:providerId, and registers SAML providers through the same/sso/registerendpoint with a nestedsamlConfig.Changes
register_saml_provideraction onsys_sso_provider(Setup → SSO Providers) — collects flat IdP fields (providerId, IdP EntityID, domain, IdP SSO URL, IdP signing cert PEM, NameID format).runRegisterSamlProviderFromFormbridge (sibling of the OIDC one inregister-sso-provider.ts) — reshapes the flat form into the nestedsamlConfig(entryPoint/cert/callbackUrl/spMetadata/identifierFormat), derives the per-provider ACS URL, defaults the SP descriptor, and re-dispatches through/sso/registerso the admin gate runs. Returns the SP ACS + metadata URLs to configure on the IdP./api/v1/auth/admin/sso/register-samladmin route inauth-plugin.ts.saml_register_failed).Verification
Suites green:
plugin-auth220,platform-objects63. Build green.E2E against a test IdP (mocksaml-style config):
POST /admin/sso/register-saml→ 200, provider persisted insys_sso_providerwithsaml_configset (oidc_confignull).GET /sso/saml2/sp/metadata?providerId=...→ 200, valid SAMLEntityDescriptor/SPSSODescriptor/AssertionConsumerService.POST /sign-in/ssowith an@example.comemail → returns a validSAMLRequestredirect to the IdP'sentryPoint.The IdP→ACS assertion round-trip (signature/replay/timestamp validation) is
@better-auth/sso/ samlify's tested responsibility.🤖 Generated with Claude Code