fix(auth): make the SSO-provider registration form produce a usable IdP (ADR-0024 / cloud#551)#2386
Merged
Merged
Conversation
…dP (ADR-0024 / cloud#551) The sys_sso_provider `register_sso_provider` UI action posted FLAT form fields to @better-auth/sso's /sso/register, which expects the OIDC fields NESTED under `oidcConfig`. Top-level clientId/clientSecret were Zod-stripped, so the form persisted an `oidc_config = null` provider that could never complete a login. - plugin-auth: shared `runRegisterSsoProviderFromForm` helper reshapes the flat body to nested and re-dispatches through the real /sso/register (so the admin gate + public-IdP trustedOrigins allowance + discovery hydration run); exposed via a new /admin/sso/register bridge on the host AuthPlugin. The cloud per-env AuthProxyPlugin mounts the same helper (mirrors set-initial-password). - platform-objects: register action retargets to /admin/sso/register and gains discoveryEndpoint, scopes, and attribute-mapping (mapId/mapEmail/mapName) fields. Keeps runtime self-service IdP registration in the OSS edition (open mechanism). Verified E2E: admin registers an IdP from the flat form → a member logs in through it (JIT, sys_account.provider_id set); a non-admin is rejected 403. 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.
Why
Follow-up to the cloud#551 SSO work (#2363 admin-gate, #2370 public-IdP trust). The open-source
sys_sso_providerregistration form was broken: itsregister_sso_provideraction posts FLAT fields to@better-auth/sso's/sso/register, which expects the OIDC fields NESTED underoidcConfig. Top-levelclientId/clientSecretget Zod-stripped → the form silently persists anoidc_config = nullprovider that returns "Invalid SSO provider" on login. So an admin could not actually configure a working IdP through the UI.What
runRegisterSsoProviderFromFormhelper reshapes the flat form body into the nested shape and re-dispatches it through the real/sso/register(so the admin gate, the public-routabletrustedOriginsallowance, discovery hydration, and secret handling all still run — zero logic duplicated). Exposed via a new/admin/sso/registerbridge on the hostAuthPlugin. The cloud per-environment runtime mounts the same helper in itsAuthProxyPlugin(separate cloud PR) — mirrors howset-initial-passwordstays in lockstep across the two mount points.register_sso_providerretargets to/api/v1/auth/admin/sso/registerand gainsdiscoveryEndpoint,scopes, and attribute-mapping (mapId/mapEmail/mapName) fields.This keeps runtime self-service IdP registration in the OSS edition — the open mechanism — rather than gating the config UI behind a paid tier.
Verification (browser E2E, local prod-like stack)
/admin/sso/register) → 200; the provider has a populatedoidcConfig(sign-in/sso returns a real authorize URL — wasoidc_config:null→ "Invalid SSO provider").alice@acme.example.com;list-accounts→providerId= the form-registered IdP.🤖 Generated with Claude Code