Skip to content

fix(auth): the direct sign-in door accepts the state an identity provider echoes after sign-out - #35585

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-aru6wr
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-aru6wr

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #35474

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:开启“退出后回到身份提供方登录页”的部署里,若退出时带了状态值,身份提供方送回时原本停在一个报错页,现在直接看到身份提供方的登录页;不带状态值的退出(随附控制台的做法)前后一样。
  • 为什么做:补齐“退出后经身份提供方登录页返回”这一能力,替托管环境的退出回程解决一个按标准协议发送状态值就会断掉的问题。
  • 出错会怎样:碰到的是自行发送状态值的宿主或客户端,最坏情况是退出后仍停在报错页、保持已退出(不会误登录);改动很小,可直接撤回。
  • 要你做什么:无

What changes

  • packages/plugins/plugin-auth/src/direct-sign-in.ts: the direct sign-in door's closed query set (DIRECT_SIGN_IN_QUERY_PARAMS) is now callbackURL and state, each accepted at most once. state is never read and never forwarded into the new authorize: the door starts a fresh sign-in with the vendor's own state cookie, exactly as without it. The repeated-name check now runs over the whole set, so ?state=a&state=b answers 400 VALIDATION_ERROR with the shared repeated-parameter sentence, like a repeated callbackURL. Any other name is still refused 400 (AGENTS.md route rule 5 stands: nothing outside the declared set is dropped). The docblock says why state is there: under afterSignOut: 'identity-provider' the door is the post-logout redirect URI, and the provider echoes the /sign-out body's state onto it (OpenID Connect RP-Initiated Logout 1.0 §3).
  • auth-route-ledger.ts: the GET /api/v1/auth/sign-in/direct note gains one clause for the accepted, unread state.
  • content/docs/permissions/sso.mdx: one sentence in "Sign-out through the identity provider".
  • Patch changeset for @objectstack/plugin-auth.

Choice pinned (the card's Done-when offered three): accept and ignore. Round-tripping has no target (the door's next hop is a fresh authorize, not the RP that minted the value), and documenting "callers must not send one" would leave /sign-out's own declared state body member (sso-sign-out-of-idp.ts SignOutBody, forwarded by oidcEndSessionUrl) breaking the documented return that published contract text promises (auth-endpoints.zod.ts afterSignOut: "identity-provider sends it back through GET /auth/sign-in/direct, so the identity provider shows its own sign-in page").

Read first, by risk:

  1. direct-sign-in.ts runDirectSignIn, the refusal block (the repeated computation): the arity rule now spans both names, and the unknown-name sentence still outranks it.
  2. direct-sign-in.ts DIRECT_SIGN_IN_QUERY_PARAMS docblock: the reason state is a declared, value-ignored member.
  3. direct-sign-in.test.ts, the last top-level describe (the card's pins).

Two-minute check: pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/direct-sign-in.test.ts should print Tests 121 passed (121).

Why

Measured on origin/main b65488a: the door answered 400 VALIDATION_ERROR for ?callbackURL=/x&state=abc and for the bare post-logout return ?state=abc. state reaches the door because the Console (and any client) sets the sign-out callbackURL, the post-logout redirect URI, to {basePath}/sign-in/direct under afterSignOut: 'identity-provider' (ui/packages/auth/src/createAuthClient.ts signOutReturn), /sign-out forwards a body state to the provider's end-session endpoint, and the provider appends it on the redirect back. That includes the platform acting as provider: @better-auth/oauth-provider 1.7.12 getRegisteredLogoutRedirect does redirectURI.searchParams.set("state", state). The shipped Console sends no state, so the UI did not reach this; a host or client that does, as OIDC allows, did.

Tests

New top-level describe in the shared-harness file direct-sign-in.test.ts (AGENTS.md: a pin for a component with a shared harness goes into that file):

  • ?callbackURL=%2Fx&state=rp-opaque-abc answers the same 302 location as without state; the vendor start received a byte-equal body, and the echoed value appears nowhere in it.
  • Mounted (real AuthPlugin routes over a real AuthManager, afterSignOut: 'identity-provider'): GET /api/v1/auth/sign-in/direct?state=rp-opaque-abc answers 302 to the identity provider's authorize with the vendor's own state, not the echoed one.
  • ?callbackURL=%2Fx&state=a&state=b answers 400 with error equal to { code: 'VALIDATION_ERROR', message: repeatedQueryParamMessage('state', 2) }, and nothing is started.
  • CONTROL: ?state=a&next=%2F is still refused 400 VALIDATION_ERROR, starting nothing.
Readings (head 0cb0699)
  • pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/direct-sign-in.test.ts: Test Files 1 passed (1), Tests 121 passed (121), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/plugin-auth test: Test Files 287 passed (287), Tests 6032 passed | 10 skipped (6042).
  • pnpm --filter @objectstack/plugin-auth build && pnpm --filter @objectstack/plugin-auth typecheck: lock VERDICT command-exit 0; check:test-typecheck: OK.
  • Ablation (committed fix first; test imports ./direct-sign-in from src, no dist leg): node scripts/ablation-replace.mjs set back to ['callbackURL'], anchor 1 to 0, blob ab1f0608 to e55cbc2f; run: Tests 3 failed | 118 passed (121), the three state pins red (pass-through, mounted bare return, repeated-state sentence), the unknown-name CONTROL green; restored blob == HEAD (ab1f060808fc) and git diff HEAD is empty.
  • node scripts/pm/dispatch-gates.mjs --commands (derived at 0cb0699): 101 commands run; --ran with exit codes: 101 derived famil(ies) accounted for — 98 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3). All 98 exit 0.
  • NOT MEASURED (exit 3, prerequisite outside this diff's closure): check-plugin-teardown-shape.mjs --self-test (pinned fixture commit unreachable in this shallow clone), @objectstack/spec check:skill-examples (packages/client-react/dist not built), check:dual-build-cjs-loads (a package with no dist). CI runs all three.
  • node scripts/pm/overlap-check.mjs --branch=HEAD: VERDICT clean exit 0.

Acceptance notes

  • The IP allow-list landing (directSignInNetworkRefusal) reads only callbackURL and needed no change: a blocked client with an echoed state still lands on /login?error=IP_NOT_ALLOWED.
  • Clause-②: no is the claim's reading: the refusal of an echoed state was a mis-refusal that the published afterSignOut text already negates; no new route and no new export name. The door's accepted query set does grow by one name, which the claim records as the bug fix and not a widening.
  • packages/spec/** untouched.

Verification

Local subset above; every CI-run family is read from this PR's check-runs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibyy9KSA69EGZtjDj9c

…ider echoes on the post-logout return

The door's closed query set gains `state`, accepted at most once and never
read or forwarded: under afterSignOut identity-provider the door is the
post-logout redirect URI, where the provider passes back the /sign-out state.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyy9KSA69EGZtjDj9c
@github-actions github-actions Bot added size/s 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 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 6 documentable anchor(s).

3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/deployment/environment-variables.mdx (via directSignIn (literal, a string literal in AUTH_ROUTE_LEDGER))
  • content/docs/permissions/authentication.mdx (via callbackURL (literal, a string literal in DIRECT_SIGN_IN_QUERY_PARAMS; a string literal in runDirectSignIn))
  • content/docs/permissions/sso.mdx (via callbackURL (literal, a string literal in DIRECT_SIGN_IN_QUERY_PARAMS; a string literal in runDirectSignIn), directSignIn (literal, a string literal in AUTH_ROUTE_LEDGER), /api/v1/auth/sign-in/direct (route, a path literal in AUTH_ROUTE_LEDGER))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-5.mdx (via callbackURL (literal, a string literal in DIRECT_SIGN_IN_QUERY_PARAMS; a string literal in runDirectSignIn))
  • content/docs/releases/v18/18-6.mdx (via /api/v1/auth/sign-in/direct (route, a path literal in AUTH_ROUTE_LEDGER))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 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 — 21 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 de395b428dfb58bad404e1ab67b1db01a93fa4c0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 06f0dc6c10fdfe4e41e8753eda3e84b402955241 — the merge of head 0cb06990f2f5280486d69280f505fcd64aa59691 into base de395b428dfb58bad404e1ab67b1db01a93fa4c0, 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 06f0dc6c10fdfe4e41e8753eda3e84b402955241 && git checkout 06f0dc6c10fdfe4e41e8753eda3e84b402955241
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin de395b428dfb58bad404e1ab67b1db01a93fa4c0 0cb06990f2f5280486d69280f505fcd64aa59691 && git checkout -B drift-repro de395b428dfb58bad404e1ab67b1db01a93fa4c0 && git merge --no-ff 0cb06990f2f5280486d69280f505fcd64aa59691

node scripts/docs-audit/affected-docs.mjs --json de395b428dfb58bad404e1ab67b1db01a93fa4c0

⚠️ 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 de395b428dfb58bad404e1ab67b1db01a93fa4c0 → 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

repo:objectstack#7 · os-tesla · session_01L9qibyy9KSA69EGZtjDj9c

Final head for review · 2026-11-19T16:50Z: 0cb06990f2f5280486d69280f505fcd64aa59691. Check-runs on that head read now: 40 success, 15 skipped, 0 failed, 0 running. L1 requested from the seat's L1-a thread (diff +78 / −8 over 5 files, so not the ≤50-line self-review class). Card #35474, claim 7014000854, dev report 7015177073.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

席位核对

L1: ACCEPT (L1-a, for area d7-A) at head 0cb06990f2f5280486d69280f505fcd64aa59691, read 2026-11-19T16:52Z.

Checklist (l1-review-checklist.md), read on GitHub and in the head tree, not from the report:

  • Shape. Draft, base main. The only closing keyword is Fixes #35474, which fits: the card is delivered whole. No other issue number appears in the body.
  • Scope. 5 files, +78/−8, all inside the claim's declared file surface (claim 7014000854). No content/docs/releases/ edit. packages/spec/** is untouched.
  • Changeset. @objectstack/plugin-auth patch. Both declaration lines sit at line start in the changeset and the PR body. Check Changeset is success.
  • The point d7-A asked me to judge: Clause-②: no. I accept the claim's reading, under execution-duties.md's rule that removing a mis-refusal the published contract text already negates is no, provided the no cites that text. The cite fits:
    • The afterSignOut describe in packages/spec/src/api/auth-endpoints.zod.ts promises that identity-provider "sends it back through GET /auth/sign-in/direct, so the identity provider shows its own sign-in page".
    • /sign-out already takes a body state (sso-sign-out-of-idp.ts SignOutBody) and forwards it to the end-session URL (oidcEndSessionUrl, searchParams.set('state', …)). Per RP-Initiated Logout 1.0 §3, the provider echoes it onto the redirect.
    • A 400 on that echo therefore contradicts the published promise.
    • The old refusal was the door's generic closed-set guard (route rule 5), not a deliberate refusal of state. No test on main pins state as refused, so this is not a ruling guard, security refusal or fail-closed being removed.
    • It is also not a runtime security-boundary change. The door is public and mints nothing, and anyone could already GET it without state and get the same 302. The value is never read, compared or forwarded, which the pins assert. The platform does not mint the sign-out state itself (it forwards a client-supplied one), so the door has nothing to verify it against.
    • No new route, no new export name. DIRECT_SIGN_IN_QUERY_PARAMS keeps its readonly string[] type. Route rule 5 still holds: every other name is refused, and the CONTROL pin shows it.
  • Code. In the refusal block, unknownQueryParamRefusalMessage(...) ?? repeated… keeps the unknown-name sentence ahead of the repeated one. repeated walks the declared set in order, so a repeated callbackURL still answers the same sentence as before. directSignInNetworkRefusal reads only callbackURL, so it is unaffected.
  • Tests. Four pins in the shared-harness file, which is the right home under AGENTS.md.
    • The refusal pins assert status 400 and error.code VALIDATION_ERROR (the full error object on the repeated case).
    • The positive pins assert a byte-equal vendor start body, a 302 to the IdP authorize, and that the echoed value appears nowhere in it.
    • Positive control: ablating back to ['callbackURL'] turns the three state pins red while CONTROL stays green, and the restore was verified blob-equal.
  • Prose checked against the diff.
    • Changeset: "the door answered 400 VALIDATION_ERROR instead of showing the identity provider's sign-in page" (true on main, unknown-name path); "accepts one state and ignores it … starts a new sign-in with its own state" (pins 1 and 2); "A state sent twice is still refused 400" (pin 3); "any other unknown query parameter is refused as before" (CONTROL); "The shipped Console sends no state" (ui/packages/auth/src/createAuthClient.ts signOut sends { callbackURL } only).
    • sso.mdx: "accepted once and ignored, since the door starts a new sign-in with its own" is true.
    • No other copy of the door's query set exists in content/docs or the plugin.
  • Gates. CI at 0cb06990: 55 check runs, every one success or skipped, including Lint & Repo Gates, TypeScript Type Check, Test Core and Build Docs (all success). The three locally NOT-MEASURED families are named with their reasons and are covered by CI.
  • Accepted deviations. The branch is claude/project-thread-aru6wr, the declared platform exception in the claim. The pins went into the shared harness file instead of a new file.
  • Nit, no change owed. The ledger note says "as the post-logout return under afterSignOut identity-provider it accepts one state". The door accepts one state whatever afterSignOut reads; the clause names why it is there, not a condition. Harmless.
  • Contract review. None owed. There is no Clause-②: yes, no narrowing, no packages/spec/src/** and no governed path. .changeset and content/docs are prose faces, checked sentence by sentence above.
  • Out of scope / filings. None.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyy9KSA69EGZtjDj9c

Landing · 2026-11-19T16:53Z · head 0cb06990f2f5280486d69280f505fcd64aa59691 · L1 ACCEPT 7015876936 (L1-a); no L2 owed (Clause-② no, no packages/spec/src/**, no narrowing arm)

Probe Reading
check-governed-merges.mjs --pr 35585 NOT governed · 0 of 5 paths hit the register · +78 / −8 = 86 lines ≤ 3000
Check-runs at head 55: 40 success, 15 skipped, 0 failed
K (rev-list --count --first-parent PRBASE..origin/main, PRBASE de395b42 from Test Core's Affected-set diff base) 5 (< 15); no shared-budget input touched

State: ready + auto-merge now; #35474 closes on merge.

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/s 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.

Direct sign-in door answers 400 when an RP-initiated logout returns to it with state

2 participants