Skip to content

feat(plugin-auth): an SSO provider can sign the person out of the company sign-in too, per provider and off by default - #33170

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-ur0eh0
Nov 14, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-ur0eh0

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Clause-②: yes (widening)
Metadata-protocol: added

Part of #32087

维护者速读

  • 改了什么:每个 SSO 提供方新增「退出时同时退出公司登录」开关(默认关闭,改动进审计)。开启后,退出平台也会结束身份提供方的会话:SAML 走单点登出,OIDC 走带 id_token_hint 的登出跳转。
  • 为什么改:SSO end-user UX: every refusal says "the sign-in link expired", internal terms reach end users, a refused IdP-initiated sign-in is silent, and Log out leaves the IdP session so the next click signs straight back in #32087 第 4 项,Tesla 选 A(裁定 6866334319):企业可以按提供方要求「退出平台即退出公司登录」。
  • 风险与回滚:开关默认关闭,现有提供方的退出行为不变;SAML 登出端点只在开关开启时打开,且只接受已签名的登出消息。回滚即还原本 PR,新增列默认值为 false。
  • 先看: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/sso as a provider additional field, so the vendor's own /sso/register and /sso/update-provider take it as signOutOfIdp, 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-out also ends the identity provider's session, and answers better-auth's own { success, url, redirect } shape (a Location header unless disableRedirect):

  • SAML single logout. The vendor's enableSingleLogout is 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/:providerId opens, only while the switch is on. wantLogoutRequestSigned and wantLogoutResponseSigned are always true. Sign-out runs the vendor's own SP-initiated /sso/saml2/logout/:providerId and 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's idpMetadata.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.
  • OIDC RP-initiated logout. The sign-in at a provider whose switch is on records the session's provider. Sign-out runs the platform's own sign-out unchanged, then answers the provider's end_session_endpoint with id_token_hint (the ID token of that sign-in), client_id, post_logout_redirect_uri (only for a callbackURL on a trusted origin) and state. The endpoint is read from the provider's discovery document when the switch is saved on, and kept in its stored oidc_config as endSessionEndpoint.

Saving the switch on is refused 400 VALIDATION_FAILED on signOutOfIdp for a provider that cannot honour it: SAML with no logout address; OIDC whose discovery document cannot be read, names no end_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 a samlify identity provider:
    • CONTROL, switch off: the identity provider's signed LogoutRequest is refused SINGLE_LOGOUT_NOT_ENABLED and the session stands; sign-out answers no url.
    • On: sign-out answers the IdP logout URL with a LogoutRequest for that person, and the session ends.
    • On: an unsigned LogoutRequest and an unsigned LogoutResponse are each refused; the signed LogoutResponse lands.
    • On: a signed message in the HTTP-Redirect binding is refused (fail closed).
    • On: a signed LogoutRequest naming one person ends that person's session only, and answers the identity provider.
    • The SP metadata advertises SingleLogoutService only while the switch is on.
  • sso-oidc-refusal-cause.test.ts, "sign out of the company sign-in too: OIDC logout redirect": CONTROL off (no url, nothing recorded); on (the url is the end_session_endpoint with id_token_hint equal to the signed-in ID token, client_id, post_logout_redirect_uri, state, Location set, the session ends); an untrusted callbackURL is not passed on.
  • sso-provider-lifecycle.test.ts, "saved on only for a provider that can honour it": the refusals through /sso/update-provider for 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-provider enableSingleLogout scope and the always-signed logout flags. auth-session-audit.test.ts: the SAML logout path writes a logout row.

Ablation: wantLogoutRequestSigned / wantLogoutResponseSigned set to false in ssoSamlOptions() through scripts/ablation-replace.mjs (anchor 1 → 0 on disk): the unsigned-message pin and the redirect-binding pin go red; restored, blob equal to HEAD and git diff HEAD empty, green again.

Acceptance notes

Remainders, not in this PR:

  • The Console: the sign-out following the answered 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/sso 1.7.12 and noted for the reviewer:

  • The vendor verifies no HTTP-Redirect binding signature on an incoming logout message, so a signed redirect-binding message is refused; identity providers must send logout messages in the HTTP-POST binding.
  • The vendor's outgoing LogoutRequest carries no RelayState, so after the identity provider's logout the person lands on the app's root, and the LogoutRequest is signed only when the provider's SAML configuration asks for it.
  • Only sessions started while the switch is on are covered; an older session signs out of the platform only.
  • The shared OIDC callback without a provider id is not recorded (no provider here sets a redirectURI).
  • A logout the identity provider starts ends the platform session but is not written as a logout audit row.

Verification

  • The four test files above, and the full suites: @objectstack/plugin-auth 267 files / 5072 tests and @objectstack/platform-objects 121 files / 1955 tests, all green.
  • tsc --noEmit for both packages; the translation bundles regenerated with node scripts/check-i18n-bundles.mjs --write.
  • Every gate node scripts/pm/dispatch-gates.mjs --commands derives (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

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/plugin-auth, touching 130 documentable anchor(s).

59 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 5e250a65992192bdc9b3fb3be304a2fca245b2d1.

⛔ 15 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 anchor(s) matched too much of the corpus to be a work list: VALIDATION_FAILED (literal, 46 pages), created_at (literal, 43 pages)
  • 12 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 24 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 5e250a65992192bdc9b3fb3be304a2fca245b2d1 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 3976902a6a6d887977c3b0ec390932927a9c1a86 — the merge of head b3291114e08643d73f00d94f1b5a30b347ae20cb into base 5e250a65992192bdc9b3fb3be304a2fca245b2d1, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 5e250a65992192bdc9b3fb3be304a2fca245b2d1 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-tesla · session_01L9qibwMmGJKaQ52CgHqNu2

Contract review

Served-tier: TIER_DEFAULT
Head-sha: b3291114e08643d73f00d94f1b5a30b347ae20cb
Local-runs: none

① Derived judgments

  • Clause-②: yes (widening) holds against the diff. sys_sso_provider gains one boolean column, sign_out_of_idp, default false with trackHistory. The vendor provider record gains the matching additional field. Edit Sign-In Options gains a param, and Register SAML Provider and Edit SAML Settings gain an optional logoutUrl, stored as the provider's single logout service with no new column. Every existing provider reads false, so sign-out and the two SAML logout endpoints answer as before; nothing served before is refused.
  • The ruling (6866334319, item 4 → A) is met arm by arm. The switch is per provider, off by default, and audited. With it on, SAML signs out through single logout and OIDC through an RP-initiated redirect that carries id_token_hint. Incoming logout messages are accepted only when signed: both signature flags are forced on with the switch, and the ablation turns the two unsigned pins red. Saving the switch on for a provider that cannot honour it answers 400 VALIDATION_FAILED on signOutOfIdp. With the switch off, the provider's incoming logout endpoint stays closed (pinned).
  • The OIDC post_logout_redirect_uri is set only for a trusted origin, and the end_session_endpoint is accepted only on a trusted origin at save time. When the provider row or its options cannot be read, the scope falls back to switch off.
  • Metadata-protocol: added holds: one new field on a platform object plus additive action params.

② Semver level

minor for @objectstack/plugin-auth and @objectstack/platform-objects, as the changeset declares: additive surface only, with nothing removed or narrowed.

③ Boundary flags

  • No packages/spec change and no governed path (check-governed-merges --pr 33170: not governed).
  • The vendor (@better-auth/sso 1.7.12) is not patched. Its single-logout options are answered per request from the provider's scope.
  • The generated translation bundles move with the new column and params, and no hand-written locale string is added.
  • Remainders named in the PR, outside this review: the Console sign-out following the answered url, and any form item the form does not render by itself (the ui card). Sessions that started before the switch was turned on sign out of the platform only.
  • Nits, with no effect on correctness or the contract: samlLogoutServiceOf accepts an http: IdP logout address, matching the other SAML address fields; the 7-day expiry fallback for a recorded OIDC session is an unnamed constant.

Implemented-by: session_01L9qibz44EJYWFvzJTmGHkg
Reviewed-by: session_01L9qibwMmGJKaQ52CgHqNu2

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-tesla · session_01L9qibwMmGJKaQ52CgHqNu2

ACCEPT · 2026-11-14T00:24Z · PR #33170 · head b3291114

  1. Shape: Part of #32087 (item 4, server half), base main, 39 files (+1754/−34): sys_sso_provider (one column, one action param, two optional SAML params, the list column), the plugin-auth sign-in options, provider bridges, sign-out and OIDC callback with tests, the regenerated translation bundles, and one changeset (@objectstack/plugin-auth and @objectstack/platform-objects, minor). Clause-②: yes (widening), Metadata-protocol: added, matching claim 6866398944 as amended by 6866461130. Assignee os-tesla. Author objectstack-fleet[bot].
  2. Premise: ruling 6866334319, item 4 → A. Each SSO provider gets a "sign out of the company sign-in too" switch, off by default and audited. With it on, sign-out also ends the identity provider session, and incoming logout messages are accepted only when signed. Saving it on for a provider that cannot honour it is refused.
  3. Contract review: owed on the declaration face (TIER_DEFAULT). Record 6867843190 PASS on this head. Its two nits are accepted deviations.
  4. Prose faces, read sentence by sentence: the changeset's paragraphs match the diff, arm by arm. The new column's description and the action params' help text say what the switch does and what it needs. The remainders are named: the Console sign-out following the answered URL, and any form item the form does not render by itself (the ui card).
  5. Gates / check-runs: dev: 77 derived gates reconciled with --ran, every exit 0; plugin-auth 5072 and platform-objects 1955 tests pass; ablation of the signed-logout requirement red, then restored. On head b3291114: 51 runs, 35 success, 16 skipped, 0 failed, 0 running; mergeable_state clean. check-governed-merges --pr 33170: NOT governed.
  6. Landing: not governed, 1788 changed lines (under the human-merge threshold), K = 3 (PRBASE 5e250a65, no new locale pack). The seat readies the PR and arms auto-merge under the maintainer's standing word 「车道经理应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-13).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants