Repository navigation
fix(auth)!: the environment-access gate on /oauth2/authorize judges every client the request names - #33937
Conversation
…very client the request names The ADR-0069 D5.1 gate now collects every client the authorize request names, from the query and from the body (a string or an array, de-duplicated), judges each one, and refuses with its existing refusal (403 ENV_ACCESS_DENIED, or the redirect / page a browser already gets) if any one is refused. A request that names no client anywhere is unchanged. Pins: GET refused; form POST refused (envelope and page); JSON POST answers the provider's 415; a query/body pair refused in either order; a two-client body refused; a client named twice judged once; controls for an admitted form POST and a request naming no client; a denying gate on each resume pass (sign-in, /oauth2/consent, /oauth2/continue) with an admitting control. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…-judges-every-client-id
…-judges-every-client-id
…-judges-every-client-id
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Contract-review-handoff: review#1 — CONTRACT_REVIEW_TIER unavailable (the maintainer routes this account's contract reviews to review#1, 2026-11-15T14:38Z) · head a65fcc6 A no-card security#1 order. The reviewer reads the advisory through the relay. The maintainer cleared this fix to land through the normal flow. Seat notes:
Generated by Claude Code |
📓 Docs Drift CheckThis PR changes 1 package(s): ⛔ 1 release-owned page(s) 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 a91fe353ff439fa58e18fd3491d5ce8496636474 && git checkout a91fe353ff439fa58e18fd3491d5ce8496636474
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 03b4d2d1f49fdb8cc4f0004724979305d8902266 8e83084f92bfc32568b2d4ce95087f468fad3466 && git checkout -B drift-repro 03b4d2d1f49fdb8cc4f0004724979305d8902266 && git merge --no-ff 8e83084f92bfc32568b2d4ce95087f468fad3466
node scripts/docs-audit/affected-docs.mjs --json 03b4d2d1f49fdb8cc4f0004724979305d8902266
|
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head a65fcc6 · 2026-11-15T15:01Z |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Contract-review-handoff: review#2 — CONTRACT_REVIEW_TIER unavailable (review#1 went off duty and handed its work to review#2; the maintainer routes contract-tier reviews to the review seat, 2026-11-15T15:03Z) · head a65fcc6 The handoff of 6896228998 named review#1, whose mailbox had already closed. This line replaces it. |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T15:08Z. First review of this head; claim: comment 6896517644; lane request 6896555900 on mailbox #33873. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. First review of this head. The net diff against main is the four files above; the ① Derived judgmentsThe rule the gate must keep: an authenticated subject is handed an authorization code for a client only after the host's
② Semver level
CI on this head: 57 check-runs, 37 success, 20 skipped, none running, none failed; ③ Boundary flags
④ Design judgmentThe narrowing makes the spec's own refusal real: ADR-0069 D5.1 already says no code without the gate's admission, and the tree now keeps that for every client the endpoint can act on. It takes nothing away from a host or a client that the published contract granted. Judging both sources on every pass, rather than mirroring the provider's choice of source, is the right shape: it cannot drift when the provider's reading changes. S1 (should-fix) — the pins cover less than the body and changeset say. The leg titled for a body naming two clients holds for the ordering it sends and not for the other, so it does not pin "refused if any one is refused" for that source; and no leg reaches the repeated-parameter arm or the non-string arm of S2 (should-fix) — the N1 (nit) — the changeset's "each a string or an array" describes the collector's input, not what a caller can send through every transport; one clause saying so would keep a host from reading it as a promise. No must-fix. Implemented-by: VERDICT: PASS |
…tate the per-client calls in the gate's contract - one leg per arm: a query naming client_id twice is refused with each client judged by itself, in both orders; a resume pass whose body names a non-string client_id is judged on that value - the two-client form-body leg now states what it measures, in both orders: no code unless the gate judged and admitted the client - the oidcAuthorizeGate jsdoc states the gate can be called once for each distinct client the request names - the changeset says "each a string or an array" describes what the gate collects, not what every transport accepts Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Delta review requested from review#2 (the original reviewer, record 6896611665): range
|
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 8a779de · 2026-11-15T15:46Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T15:50Z. Claim: comment 6897101787; lane request 6897095503 on mailbox #33873. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. Delta review. Record 6896611665 judged head ① Derived judgmentsThe rule is unchanged from record 6896611665: an authenticated subject is handed an authorization code for a client only after the host's One sentence of that record I restate more exactly, because the new non-string leg shows it: on a resume pass the gate reads the resume endpoint's body as the caller sent it, not a validated subset. That is on the fail-closed side (the gate can only be asked about more, never fewer, than the provider acts on), a caller can only ever get their own request refused by it, and the legitimate resume bodies name no client. The judgment "no legitimate flow newly moves except a request naming two different clients" holds. The delta, change by change:
② Semver levelUnchanged and still right: CI on this head: there is none. The check-runs listing for ③ Boundary flags
④ Design judgmentThe narrowing still makes the spec's own refusal real and takes nothing the published contract granted; the delta only pins and documents it. S1: closed. Each new leg read against the arm it pins, asking whether the leg goes red with the arm gone:
S2: closed. The N1: closed. The changeset says the string-or-array form is what the gate collects, not a promise about every transport. N2 (nit): the form-body leg's code-issued branch asserts which clients the gate was asked about, not which client the code belongs to; the two clients share a redirect URI, so the leg cannot tell them apart. The PR body words it as "issued a code only for a client the gate judged and admitted", which is a little more than the leg measures. The tree keeps the rule (gate and provider read the same parsed value); giving the two clients distinguishable callbacks would let the leg say what the body says. N3 (nit): the PR body's quick-verify line still expects 27 tests where its own Readings say 31 on this head, and it lists the non-string leg under the resume describe while the tree has it in the first describe. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
…-judges-every-client-id Keeps both declarations at the shared insertion point in auth-manager-before-hook.ts: the authorize gate's client collection and the cloud-managed reset doors from main. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Merge-only delta requested from review#2 (record 6897150150 on
|
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 8e83084 · 2026-11-15T16:03Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T16:28Z. Claim: comment 6897314363; merge-only delta requested in comment 6897301136. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. CI re-read by the seat after the last run completed: 56 runs, 37 success, 18 skipped, 1 cancelled (a superseded Merge-delta review. Record 6897150150 judged head ① Derived judgmentsThe rule is the one record 6897150150 judged: an authenticated subject is handed an authorization code for a client only after the host's
② Semver levelUnchanged and still right: CI on this head: started, not finished. 53 check-runs at the time of reading. Completed and green: Plainly, for the seat: this PASS is a verdict on the tree as read, rendered while the checks run. The five legs that closed S1 have still not been measured by a machine on any head of this PR, so do not act on this record until ③ Boundary flags
④ Design judgmentThe narrowing still makes the spec's own refusal real and takes nothing the published contract granted. Per scope file, after the merge:
N2 (nit): carried unchanged. The form-body leg's code-issued branch asserts which clients the gate was asked about, not which client the code belongs to. N3 (nit): carried unchanged. The PR body's quick-verify line still expects 27 tests where its own Readings say 31. No new finding in this round. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f 席位核对ACCEPT at
Implemented-by: os-dev (security#1 order, |
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under
skills/**and no hand-written page undercontent/docs/**teachesoidcAuthorizeGateor the authorize endpoint's environment-access gate.维护者速读
/oauth2/authorize上的环境访问门(oidcAuthorizeGate)现在对请求点名的每一个客户端逐一裁决(查询串与请求体里的client_id,字符串或数组,去重),任一被拒即以现有的 403ENV_ACCESS_DENIED拒绝。oidcAuthorizeGate的部署(托管控制面);开源版与自托管不设,行为不变。回滚即 revert 本提交。packages/plugins/plugin-auth/src/auth-manager-before-hook.ts(authorizeRequestClientIds与门的循环)、packages/plugins/plugin-auth/src/oauth-authorize-refusal.test.ts(新增两个 describe)、.changeset/authorize-gate-judges-every-client-id.md。pnpm --filter @objectstack/plugin-auth exec vitest run src/oauth-authorize-refusal.test.ts,预期 31 个测试全绿。What changes
The ADR-0069 D5.1 environment-access gate on
/oauth2/authorizejudges every client the request names: the query'sclient_idand the body'sclient_id, each a string or an array, de-duplicated (query first). It refuses with its existing refusal if any one is refused:403 ENV_ACCESS_DENIEDfor a fetch or API client, and for a browser the redirect or readable page it already gets (oauth-authorize-refusal.ts, unchanged). A request that names no client anywhere is unchanged, and so is an unauthenticated request.BREAKING only for a host whose
oidcAuthorizeGateassumes one call per request: it can now be called once per distinct client named. The callback signature does not change.Tests
packages/plugins/plugin-auth/src/oauth-authorize-refusal.test.ts(realAuthManager+@better-auth/oauth-provider), two new top-level describes in the existing harness:POST /oauth2/consent,POST /oauth2/continue, each with a denying-gate leg (refused) and an admitting control (code). A resume pass naming a client that is not a string is judged on that value and refused when it is refused.packages/qa/dogfood/test/oidc-authorize-env-gate.dogfood.test.ts: form POST naming the client in the body refused; query/body pair refused; CONTROL admitting gate hands a code.Acceptance notes
auth-manager-before-hook.ts. It landed first, and the merge at8e83084f92keeps both declarations.Verification
Readings
Tests 4 failed | 23 passed (27); every resume-pass leg was already green.Tests 27 passed (27). Ablation of the body read: the same 4 red, restored to the HEAD blob.pnpm --filter @objectstack/plugin-auth testatf050ae909b:Test Files 277 passed (277),Tests 5501 passed | 10 skipped; typecheck OK (lock VERDICT command-exit 0). The heada65fcc623dadds only apackages/climerge from main.fed9ed9668: 70 derived, 69 run, 1 NOT-MEASURED (check:dual-build-cjs-loads, prerequisite dist; CI runs it).fed9ed9668:Tests 3962 passed | 42 skipped (4004), VERDICT command-exit 0.a65fcc623d:Test Files 467 passed | 3 skipped (470)·Tests 3962 passed | 42 skipped (4004), no failures, VERDICT command-exit 0. It carries to8a779dea16, whose diff changes only tests, a jsdoc comment and the changeset.8a779dea16:oauth-authorize-refusal.test.tsTests 31 passed (31). Ablation of the repeated-parameter arm: 2 red. Ablation of the non-string arm: 1 red. Both restored to the HEAD blob. plugin-authTests 5505 passed | 10 skipped, and typecheck OK. The changeset gates and the 9 gate families added byauth-manager.tsall exit 0.8e83084f92, after PR 33268 landed at the same insertion point inauth-manager-before-hook.ts. The conflict was positional and both declarations are kept, with no line of either changed. plugin-auth at that tree:Test Files 277 passed (277)·Tests 5515 passed | 10 skipped (5525), and typecheck OK.Generated by Claude Code