Repository navigation
feat(plugin-auth): an SSO provider can sign the person out of the company sign-in too, per provider and off by default - #33170
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
…e switch Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
… through Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg
📓 Docs Drift CheckThis PR changes 2 package(s): 59 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 15 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 24 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 3976902a6a6d887977c3b0ec390932927a9c1a86 && git checkout 3976902a6a6d887977c3b0ec390932927a9c1a86
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5e250a65992192bdc9b3fb3be304a2fca245b2d1 b3291114e08643d73f00d94f1b5a30b347ae20cb && git checkout -B drift-repro 5e250a65992192bdc9b3fb3be304a2fca245b2d1 && git merge --no-ff b3291114e08643d73f00d94f1b5a30b347ae20cb
node scripts/docs-audit/affected-docs.mjs --json 5e250a65992192bdc9b3fb3be304a2fca245b2d1
|
|
security#2 · os-tesla · session_01L9qibwMmGJKaQ52CgHqNu2 Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
security#2 · os-tesla · session_01L9qibwMmGJKaQ52CgHqNu2 ACCEPT · 2026-11-14T00:24Z · PR #33170 · head
|
Requested by Tesla · project thread
Clause-②: yes (widening)
Metadata-protocol: added
Part of #32087
维护者速读
packages/plugins/plugin-auth/src/sso-sign-out-of-idp.ts(退出流程与保存时的能力判定),以及sso-sign-in-options.ts里按提供方生效的 SAML 选项。pnpm --filter @objectstack/plugin-auth exec vitest run src/sso-sign-out-of-idp.test.ts src/sso-saml-refusal-landing.test.ts src/sso-oidc-refusal-cause.test.ts src/sso-provider-lifecycle.test.ts -t "sign out of the company sign-in too|single logout|logout redirect|can honour it"What changes
A new per-provider sign-in option, Sign Out of the Company Sign-In Too (
sys_sso_provider.sign_out_of_idp, boolean, default false,trackHistory). It is declared to@better-auth/ssoas a provider additional field, so the vendor's own/sso/registerand/sso/update-providertake it assignOutOfIdp, with the same writers as the other sign-in options. Edit Sign-In Options gains its param, and the provider list shows the column.With the switch on,
POST /sign-outalso ends the identity provider's session, and answers better-auth's own{ success, url, redirect }shape (aLocationheader unlessdisableRedirect):enableSingleLogoutis read per provider:ssoSamlOptions()answers it from a request scope holding the provider's column, so the ACS records the SAML session, the SP metadata advertises SingleLogoutService, and/sso/saml2/sp/slo/:providerIdopens, only while the switch is on.wantLogoutRequestSignedandwantLogoutResponseSignedare always true. Sign-out runs the vendor's own SP-initiated/sso/saml2/logout/:providerIdand answers its logout URL. The identity provider's logout address is the new optional IdP Logout URL (logoutUrl) on Register SAML Provider and Edit SAML Settings, stored as the vendor'sidpMetadata.singleLogoutService(one address under the HTTP-Redirect and HTTP-POST bindings; no new column). A sign-out through that path writes the same logout audit row as/sign-out.end_session_endpointwithid_token_hint(the ID token of that sign-in),client_id,post_logout_redirect_uri(only for acallbackURLon a trusted origin) andstate. The endpoint is read from the provider's discovery document when the switch is saved on, and kept in its storedoidc_configasendSessionEndpoint.Saving the switch on is refused
400 VALIDATION_FAILEDonsignOutOfIdpfor a provider that cannot honour it: SAML with no logout address; OIDC whose discovery document cannot be read, names noend_session_endpoint, or names one off the trusted origins. Saving it off is never refused.Tests
sso-saml-refusal-landing.test.ts, "sign out of the company sign-in too: SAML single logout", against the real vendor and asamlifyidentity provider:SINGLE_LOGOUT_NOT_ENABLEDand the session stands; sign-out answers nourl.sso-oidc-refusal-cause.test.ts, "sign out of the company sign-in too: OIDC logout redirect": CONTROL off (nourl, nothing recorded); on (theurlis theend_session_endpointwithid_token_hintequal to the signed-in ID token,client_id,post_logout_redirect_uri,state,Locationset, the session ends); an untrustedcallbackURLis not passed on.sso-provider-lifecycle.test.ts, "saved on only for a provider that can honour it": the refusals through/sso/update-providerfor SAML and OIDC with the switch left off, saving off never refused, the IdP Logout URL through the edit and register doors, and the OIDC endpoint kept on a save that lands.sso-sign-out-of-idp.test.ts: the capability judge, the IdP Logout URL mapping, the single-logout paths and the OIDC logout URL, read off their own inputs.sso-sign-in-options.test.ts: the per-providerenableSingleLogoutscope and the always-signed logout flags.auth-session-audit.test.ts: the SAML logout path writes a logout row.Ablation:
wantLogoutRequestSigned/wantLogoutResponseSignedset to false inssoSamlOptions()throughscripts/ablation-replace.mjs(anchor 1 → 0 on disk): the unsigned-message pin and the redirect-binding pin go red; restored, blob equal to HEAD andgit diff HEADempty, green again.Acceptance notes
Remainders, not in this PR:
url, and any Edit Sign-In Options / SAML form item the form does not render by itself (a later ui card).Measured on
@better-auth/sso1.7.12 and noted for the reviewer:redirectURI).Verification
@objectstack/plugin-auth267 files / 5072 tests and@objectstack/platform-objects121 files / 1955 tests, all green.tsc --noEmitfor both packages; the translation bundles regenerated withnode scripts/check-i18n-bundles.mjs --write.node scripts/pm/dispatch-gates.mjs --commandsderives (77), each run with its exit code recorded, reconciled with--ran: 77 run, 0 not measured, all exit 0. ESLint on the changed files is clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibz44EJYWFvzJTmGHkg