[GH-ISSUE #9181] tracking: SSO plugin (claim mapping, lifecycle, org scoping) #28622

Open
opened 2026-04-17 20:03:17 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @gustavovalverde on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/9181

Summary

The SSO plugin handles simple SAML and OIDC setups, but multi-tenant deployments expose unresolved behavior in provider authorization, org scoping, claim mapping, and lifecycle hooks. Provider registration and listing do not consistently enforce org boundaries. Claim and field mappings do not persist or validate the same way across flows. The provisionUser hook does not have one documented lifecycle contract. SAML and OIDC account-linking paths also apply different linking rules.

Root cause

Several SSO paths assume a single-org or single-caller model. Provider registration does not always verify org-admin authority, and provider listing does not always scope to the active org. Per-org provider limits are not exposed through one contract. Mapping rules can ignore unknown attributes instead of failing clearly. The callback hook cannot always carry client-provided context. provisionUser runs at different points than users expect, and the SAML and OIDC callbacks do not apply the same account-linking policy.

Scope

In: SSO plugin authorization on register/list/update; org-scoped provider lists and limits; claim and field mapping persistence; provisionUser lifecycle contract; SAML/OIDC account-linking policy alignment.

Out: issuer-side OAuth (tracking: oauth-provider conformance). RP provider config (tracking: generic-oauth). Invitation flow (tracking: organization invitations).

Resolution criteria

  • Registering a provider requires org-admin authorization on the target org.
  • Listing providers scopes to the active org by default.
  • Per-org provider limits are configurable and enforced.
  • Mapping rules apply symmetrically to SAML and OIDC; unknown attributes raise a clear error.
  • Callback hook receives and forwards client-provided context.
  • provisionUser fires per a documented contract, and the SAML/OIDC branches share the same account-linking policy.
  • #5772 is primary-homed in the provider-config cluster; cross-listed here for claim-mapping overlap.
  • Prior closed context: #7857, #8630 (opposite expectations for provisionUser lifecycle). The RFC body resulting from this tracker must state the chosen contract.
Originally created by @gustavovalverde on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/9181 ## Summary The SSO plugin handles simple SAML and OIDC setups, but multi-tenant deployments expose unresolved behavior in provider authorization, org scoping, claim mapping, and lifecycle hooks. Provider registration and listing do not consistently enforce org boundaries. Claim and field mappings do not persist or validate the same way across flows. The `provisionUser` hook does not have one documented lifecycle contract. SAML and OIDC account-linking paths also apply different linking rules. ## Root cause Several SSO paths assume a single-org or single-caller model. Provider registration does not always verify org-admin authority, and provider listing does not always scope to the active org. Per-org provider limits are not exposed through one contract. Mapping rules can ignore unknown attributes instead of failing clearly. The callback hook cannot always carry client-provided context. `provisionUser` runs at different points than users expect, and the SAML and OIDC callbacks do not apply the same account-linking policy. ## Scope **In:** SSO plugin authorization on register/list/update; org-scoped provider lists and limits; claim and field mapping persistence; `provisionUser` lifecycle contract; SAML/OIDC account-linking policy alignment. **Out:** issuer-side OAuth (`tracking: oauth-provider conformance`). RP provider config (`tracking: generic-oauth`). Invitation flow (`tracking: organization invitations`). ## Resolution criteria - Registering a provider requires org-admin authorization on the target org. - Listing providers scopes to the active org by default. - Per-org provider limits are configurable and enforced. - Mapping rules apply symmetrically to SAML and OIDC; unknown attributes raise a clear error. - Callback hook receives and forwards client-provided context. - `provisionUser` fires per a documented contract, and the SAML/OIDC branches share the same account-linking policy. ## Related - #5772 is primary-homed in the provider-config cluster; cross-listed here for claim-mapping overlap. - Prior closed context: #7857, #8630 (opposite expectations for provisionUser lifecycle). The RFC body resulting from this tracker must state the chosen contract.
GiteaMirror added the trackingenterpriseidentity labels 2026-04-17 20:03:17 -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#28622