Repository navigation
fix(runtime,plugin-auth)!: a banned user's OAuth access tokens and refresh grants are refused while the ban holds - #30360
Conversation
A ban holds every credential of the user, at every door that accepts an API key; a ban with an expiry stops binding once it expires. One ban predicate (isUserBanInForce) now serves every place that asks. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…resh grants are refused while the ban holds Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…double Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…gets A key refused for its owner or for the tenancy posture now resolves to the same anonymous entry as a key that does not exist, on every composition, the guest-serving one included. The restore wording in the changeset and the auth docs is qualified by each key's inactivity window. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…the ban holds Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…aude/sec-hardening-r5 Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…ponse as coded; the ban double is a bounded table filter Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…plement Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 43 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 ce22ba450713376a29c843eff83b8596d41b5500 && git checkout ce22ba450713376a29c843eff83b8596d41b5500
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 14c67d446e577926460f3ed893e44cc32cbecb12 6efeaf733aa20c6d2dd5c0a9c5a4abd322e5f200 && git checkout -B drift-repro 14c67d446e577926460f3ed893e44cc32cbecb12 && git merge --no-ff 6efeaf733aa20c6d2dd5c0a9c5a4abd322e5f200
node scripts/docs-audit/affected-docs.mjs --json 14c67d446e577926460f3ed893e44cc32cbecb12
|
The base branch's change landed on main as one squashed commit; main's copy of the two files both sides added is taken whole, and this branch's own change sits on top unchanged. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg
|
security#1 · os-sales · session_01L6bhgVfjk2i8T2D4RmxsKg Contract reviewServed-tier: ① Derived judgmentsEvery path on this head that turns an OAuth credential into a principal, or mints a new token or session for the same user, enumerated from the code and judged against the stated rule ("a ban holds every credential of the user"):
Fault classification: a thrown ban read is APIError code pin ( Tests are rule tests: the banned answer is asserted Accept-set change: the narrowing the changeset declares is exactly what the diff does at the MCP door and on the refresh arm; on the code arm the declared envelope is the uncommon case (item 4). No public export is added or removed; ② Semver level
③ Boundary flags
④ Design judgmentThe narrowing against the published behaviour on Findings:
Implemented-by: VERDICT: FAIL |
…as not valid at userinfo and introspection; the ban docs and confirmation name OAuth tokens Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg
…s the doors the rule holds at and the package the confirmation ships in Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg
…t budget Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg
|
security#1 · os-sales · session_01L6bhgVfjk2i8T2D4RmxsKg Contract reviewServed-tier: This is a DELTA record by the reviewer of the ① Derived judgmentsFindings of the
New code, in full:
Accept-set change: the narrowing the changeset declares is now exactly the set of doors the diff narrows (MCP door; token endpoint refresh and code, with the code arm's two answers spelled out; userinfo ② Semver level
③ Boundary flags
④ Design judgmentThe two new doors are closed at the right seams: userinfo in the provider's own pre-answer callback on the row it already read, introspection on the produced answer because the provider's JWT path reads no row and offers no callback there. Both answer as the provider answers a token that is not valid, read the ban through the one shared predicate, write nothing, and lift with the ban. Against the published behaviour on Findings on this head:
Implemented-by: VERDICT: PASS |
|
security#1 · os-sales · session_01L6bhgVfjk2i8T2D4RmxsKg 维护者速读
席位核对 — ACCEPT · security#1 · head
|
Resolve the offboarding row in the administrator guide: keep main's hand-over step and this branch's OAuth credential clause. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg
|
security#1 · os-sales · session_01L6bhgVfjk2i8T2D4RmxsKg Contract reviewServed-tier: This is a DELTA record by the reviewer of the ① Derived judgments
② Semver levelUnchanged: ③ Boundary flags
④ Design judgmentThe hop adds no code and changes no accepted behaviour; the narrowing judged at Implemented-by: VERDICT: PASS |
|
security#1 · os-sales · session_01L6bhgVfjk2i8T2D4RmxsKg 席位核对 — ACCEPT · security#1 · head
|
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: updated here
维护者速读
/oauth2/userinfo按无效令牌应答、在/oauth2/introspect按非活动令牌应答;令牌端点不再为其签发新令牌(refresh 与授权码兑换均被拒)。封禁确认框与管理员、认证文档同步写明。pnpm --filter @objectstack/plugin-auth exec vitest run src/auth-manager.oauth-consent-organization.test.ts,预期全部通过(真实 provider 上:封禁用户的 refresh、授权码、userinfo、introspection 应答与无效凭据一致,解封或到期后恢复)。What changes
While a user's ban holds, the rule holds at these doors, and only these:
401body andWWW-Authenticateheader. An agent forward credential acting for a banned user resolves as one that does not redeem. The ban is read where the credential becomes its user (resolveExecutionContext→isOAuthSubjectBanned,packages/runtime/src/security/oauth-subject-ban.ts), with the shared predicateisUserBanInForcefrom@objectstack/core. The verifier (verifyMcpAccessToken) stays the local, I/O-free signature check.refresh_tokengrant is answered as an invalid refresh token (400 invalid_grant,invalid refresh token) and writes nothing. Anauthorization_codeexchange is refused and the code is spent: when the ban ended the user's sessions, as the ban routes do, the provider's own session answer refuses it (400 invalid_request); otherwise it is answered as an invalid code (400 invalid_grant,invalid code). Any extension grant that issues through the provider is refused as an invalid grant. The refusal runs in the provider's callbackcustomTokenResponseFields, which receives the user row the provider already read (packages/plugins/plugin-auth/src/oauth-grant-ban-refusal.ts; its header records the order on each grant and why this hook)./oauth2/userinfoanswers a banned user's access token as an access token that does not verify (401 invalid_token, the provider's description andWWW-Authenticatechallenge), the answer a made-up token gets. It runs incustomUserInfoClaims, on the user row the provider already read, before the locale claim (packages/plugins/plugin-auth/src/oauth-token-read-ban-refusal.ts)./oauth2/introspectanswers a banned user's access and refresh tokens as inactive ({ "active": false }), the answer a made-up, expired or revoked token gets (RFC 7662 §2.2). It runs as a section of AuthManager's global after-hook, on the provider's active answer, with one read of the subject's user row through the provider's adapter (same file).sys_user(id,banned,ban_expires), as the system, per OAuth credential the MCP door resolves; one user-row read per active introspection answer that names a user; zero at the token and userinfo endpoints. A store fault on the MCP door's read is503 SERVICE_UNAVAILABLEnamingsys_user; a store fault on the introspection read fails the request (500) rather than answering active or inactive; a missing user row or an unprovisioned table keeps today's answer.packages/platform-objects/src/identity/sys-user.object.ts, its AI description and the three translated bundles),content/docs/permissions/administrator-guide.mdx(lifecycle actions and the offboarding row) andcontent/docs/permissions/authentication.mdx(theban-userroute) name OAuth access tokens and token refreshes among what a ban refuses.@objectstack/platform-objectsjoins the changeset at patch.plugin-authAPIError code pin now also reads an OAuth 2.0 error response (a literalerrorbeside anerror_description, RFC 6749 §5.2) as a coded body, with fixtures for both directions: the token-endpoint refusal must answer exactly as the provider's own error does, which carries no ADR-0112code.Tests
packages/runtime/src/security/resolve-execution-context.test.ts— new top-level describe: banned subject resolves exactly as an unverified bearer; a future expiry binds, a passed one does not; not-banned, unbanned, no-row and no-table controls admit as before; a ban read that throws is503 SERVICE_UNAVAILABLEnamingsys_user; cost pinned at one ban-column read per token and none for an unverified bearer; a forward credential for a banned user resolves as one that does not redeem.packages/plugins/plugin-auth/src/oauth-grant-ban-refusal.test.ts— the refusal against the provider's own error (class, status, body, headers) for each grant type; expiry in both spellings; not-banned and no-user controls.packages/plugins/plugin-auth/src/oauth-token-read-ban-refusal.test.ts(new) — the userinfo refusal (status, body, challenge; expiry in both spellings; controls); the introspection section (rewritten in place for a banned subject; expiry; not-banned and no-row controls; inactive, subject-less, other-path and non-object answers read nothing; a read that throws fails and leaves the answer as produced; the provider's adapter is the default reader; AuthManager's global after-hook runs the section).packages/plugins/plugin-auth/src/auth-manager.oauth-consent-organization.test.ts— on the real provider with AuthManager's own options: a banned user's refresh grant equals an invalid refresh token's answer and writes no refresh row, and renews once the ban lapses; a code issued before a ban that ended the user's sessions gets the provider's session answer, starts no refresh family and is spent; a code exchanged while the user's session survived equals a code never issued and starts no refresh family; userinfo for a banned user's token equals a made-up token's answer and reads the claims again once the ban lapses; introspection of a banned user's access and refresh tokens equals a made-up token's answer and is active again once the ban lapses; not-banned controls for each.packages/platform-objects/src/identity/action-confirm-one-dialog.test.ts— the Ban User confirmation pinned word for word, now naming OAuth access tokens and token refreshes.packages/qa/dogfood/test/oauth-banned-subject.dogfood.test.ts— booted showcase, real DCR → authorize → consent → token:initialize,query_records,create_recordand the refresh grant against a made-up token / an invalid refresh token, the refused write landing nothing; peer, unban and timed-ban controls. Its header declares its measured test budget (20 s: 13.13 s of tests, the slower of two local runs, × 1.25, rounded up).Acceptance notes
plugin-authAPIError code pin gains a third accepted shape, the RFC 6749 §5.2 error response, so a token-endpoint refusal can carry exactly the provider's own body; a literalerrorwith noerror_description, or a non-literalerror, is still reported (fixtures in both directions).Verification
Readings at head
942ee6846660unless stated. Readings marked11504e470dwere taken one commit earlier;942ee68466adds only the budget header line ofoauth-banned-subject.dogfood.test.ts.packages/runtimeis unchanged since949fd3f1e4, so its reading from that head stands.Unit and integration suites
pnpm --filter @objectstack/plugin-auth test(at11504e470d): Test Files 226 passed (226), Tests 3999 passed, 10 skipped (4009).pnpm --filter @objectstack/platform-objects test(at11504e470d): Test Files 111 passed (111), Tests 1526 passed (1526).oauth-token-read-ban-refusal.test.ts,oauth-grant-ban-refusal.test.tsandauth-manager.oauth-consent-organization.test.tstogether: Test Files 3 passed (3), Tests 29 passed (29).pnpm --filter @objectstack/runtime test(at949fd3f1e4): Test Files 542 passed (542), Tests 8651 passed, 19 skipped (8670).pnpm --filter @objectstack/plugin-auth --filter @objectstack/platform-objects run typecheck: exit 0 (bothcheck:test-typecheckOK).eslint --no-inline-configover the 19 changed.tsfiles: exit 0, no findings.node scripts/check-i18n-bundles.mjs: OK, 10 packages, all bundles in sync.Ablations (at `11504e470d`; one per refusal and one per wiring; each red, then restored, blob equal to HEAD and `git diff HEAD` empty; the restored run 29 passed of 29)
customUserInfoClaims: 1 failed of 29 (the real-provider userinfo leg).Dogfood
test/oauth-banned-subject.dogfood.test.tsalone, run twice (at11504e470d): Test Files 1 passed (1), Tests 4 passed (4), both runs; the slower took 13.13 s of tests, which gives the declared 20 s budget.942ee6846660(pnpm --filter @objectstack/dogfood test, after a build of its closure at that head): Test Files 421 passed, 3 skipped (424); Tests 3500 passed, 36 skipped (3536); 2208 s on a shared box. Nothing red: the timeout in the reading at949fd3f1e4does not recur.Gates
node scripts/pm/dispatch-gates.mjs --commandsat942ee6846660: 96 commands, each run with its exit code captured before any pipe: 96 exit 0.check:type-check-debtansweredPREREQUISITE NOT MET(exit 3) on a first pass, because the verify lock was held by this head's dogfood battery, and exit 0 when re-run.--ranreconciliation: 96 derived, 96 run, 0 NOT-MEASURED (derived from recorded exit codes).942ee6846660: 50 check runs, 38 success, 12 skipped, none failed. "Type Check · consumer gates", red atd3daa06af0because the generatedplatform-objectstranslation bundle had drifted, is green:11504e470dregenerates theenbundle.🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgVfjk2i8T2D4RmxsKg