Repository navigation
fix(auth): the direct sign-in door accepts the state an identity provider echoes after sign-out - #35585
Conversation
…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
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 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 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
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyy9KSA69EGZtjDj9c Final head for review · 2026-11-19T16:50Z: |
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH 席位核对L1: ACCEPT (L1-a, for area d7-A) at head Checklist (
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyy9KSA69EGZtjDj9c Landing · 2026-11-19T16:53Z · head
State: ready + auto-merge now; #35474 closes on merge. |
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 nowcallbackURLandstate, each accepted at most once.stateis 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=banswers400 VALIDATION_ERRORwith the shared repeated-parameter sentence, like a repeatedcallbackURL. Any other name is still refused400(AGENTS.md route rule 5 stands: nothing outside the declared set is dropped). The docblock says whystateis there: underafterSignOut: 'identity-provider'the door is the post-logout redirect URI, and the provider echoes the/sign-outbody'sstateonto it (OpenID Connect RP-Initiated Logout 1.0 §3).auth-route-ledger.ts: theGET /api/v1/auth/sign-in/directnote gains one clause for the accepted, unreadstate.content/docs/permissions/sso.mdx: one sentence in "Sign-out through the identity provider".@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 declaredstatebody member (sso-sign-out-of-idp.tsSignOutBody, forwarded byoidcEndSessionUrl) breaking the documented return that published contract text promises (auth-endpoints.zod.tsafterSignOut: "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:
direct-sign-in.tsrunDirectSignIn, the refusal block (therepeatedcomputation): the arity rule now spans both names, and the unknown-name sentence still outranks it.direct-sign-in.tsDIRECT_SIGN_IN_QUERY_PARAMSdocblock: the reasonstateis a declared, value-ignored member.direct-sign-in.test.ts, the last top-leveldescribe(the card's pins).Two-minute check:
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/direct-sign-in.test.tsshould printTests 121 passed (121).Why
Measured on origin/main b65488a: the door answered
400 VALIDATION_ERRORfor?callbackURL=/x&state=abcand for the bare post-logout return?state=abc.statereaches the door because the Console (and any client) sets the sign-outcallbackURL, the post-logout redirect URI, to{basePath}/sign-in/directunderafterSignOut: 'identity-provider'(ui/packages/auth/src/createAuthClient.tssignOutReturn),/sign-outforwards a bodystateto 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-provider1.7.12getRegisteredLogoutRedirectdoesredirectURI.searchParams.set("state", state). The shipped Console sends nostate, so the UI did not reach this; a host or client that does, as OIDC allows, did.Tests
New top-level
describein the shared-harness filedirect-sign-in.test.ts(AGENTS.md: a pin for a component with a shared harness goes into that file):?callbackURL=%2Fx&state=rp-opaque-abcanswers the same302location as withoutstate; the vendor start received a byte-equal body, and the echoed value appears nowhere in it.AuthPluginroutes over a realAuthManager,afterSignOut: 'identity-provider'):GET /api/v1/auth/sign-in/direct?state=rp-opaque-abcanswers302to the identity provider's authorize with the vendor's own state, not the echoed one.?callbackURL=%2Fx&state=a&state=banswers400witherrorequal to{ code: 'VALIDATION_ERROR', message: repeatedQueryParamMessage('state', 2) }, and nothing is started.?state=a&next=%2Fis still refused400 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), lockVERDICT 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: lockVERDICT command-exit 0;check:test-typecheck: OK../direct-sign-infrom src, no dist leg):node scripts/ablation-replace.mjsset 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; restoredblob == HEAD (ab1f060808fc) and git diff HEAD is empty.node scripts/pm/dispatch-gates.mjs --commands(derived at 0cb0699): 101 commands run;--ranwith exit codes:101 derived famil(ies) accounted for — 98 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3). All 98 exit 0.check-plugin-teardown-shape.mjs --self-test(pinned fixture commit unreachable in this shallow clone),@objectstack/spec check:skill-examples(packages/client-react/distnot 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
directSignInNetworkRefusal) reads onlycallbackURLand needed no change: a blocked client with an echoedstatestill lands on/login?error=IP_NOT_ALLOWED.Clause-②: nois the claim's reading: the refusal of an echoedstatewas 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