Repository navigation
feat(plugin-auth): the environment-access refusal carries the host's reason and sentence - #34265
Conversation
…s reason
oidcAuthorizeGate may answer { allowed: false, reason, message } in place of
false. The 403 envelope gains the validated reason and the host's sentence,
the redirect back sends the sentence as error_description plus the
objectstack_error_reason parameter, and the page shows the sentence escaped.
A boolean answer is delivered exactly as before.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…ct and the page
A boolean gate is pinned byte for byte as served at the merge base (CONTROL);
a refusal object's reason and sentence are pinned on each door, a reason
outside [a-z_]{1,40} is dropped, and a sentence that is not plain text within
the bound is replaced by the fixed sentence.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
📓 Docs Drift CheckThis PR changes 1 package(s): 57 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 15 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. 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 d4d8a87d3323888617106b4e4685aa3ed61fb760 && git checkout d4d8a87d3323888617106b4e4685aa3ed61fb760
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0241df4d6b2dc9611b382c9269665e9493101e80 749c7a2ca3fb18acbfa87c9e6b22e576824c4563 && git checkout -B drift-repro 0241df4d6b2dc9611b382c9269665e9493101e80 && git merge --no-ff 749c7a2ca3fb18acbfa87c9e6b22e576824c4563
node scripts/docs-audit/affected-docs.mjs --json 0241df4d6b2dc9611b382c9269665e9493101e80
|
…ame the client on a hand-off The environment's OAuth callback now keeps the host's validated refusal reason on its redirect to the Console sign-in page, which maps not_member and invitation_pending to their own sentences. The sign-in page reads the client name only for the client its signed request names, through a new plugin-auth read, and keeps the host line on any other answer. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
… callback answers with Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Contract reviewServed-tier: ① Derived judgments
② Semver levelpatch for plugin-auth, console and i18n: an optional field, an optional redirect parameter, one read route and three keys are added; nothing an older caller sends or reads moves. ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #34265 · S1/A1 · Fixes #34168 · head fb0d4b0 · 2026-11-16T05:58Z The area declares this head final. It carries all four items of the card:
One read is owed: review-a's ACCEPT read at this head. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Superseded · PR #34265 · 2026-11-16T06:01Z
|
…r client address The read counts a fixed window per established client address before it reads anything, in the same counter store the signed-out invitation preview uses, and answers 429 RATE_LIMIT_EXCEEDED with Retry-After over the limit. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Claim withdrawn · review-a · head fb0d4b0 · 2026-11-16T06:02Z The request was withdrawn (6908710779): a rate limit on the new read route comes first. At the next head the area declares final, review-a gives the L1 read and the TIER_DEFAULT record in one pass, reading the delta from fb0d4b0. |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #34265 · S1/A1 · Fixes #34168 · head 749c7a2 · 2026-11-16T07:32Z The area declares this head final, green on every check (58 success, 12 skipped by path). It replaces the withdrawn request 6908671938. Since then, by the seat's ruling, the new signed-out read is rate-limited per client address with the invitation-preview window, pinned and ablated; one changeset sentence and the body follow. The ADR-0138 D2 text rides #34257 (claim amendment 6908701438). It carries all four items of the card:
Owed in one pass from the review thread: the review read and the TIER_DEFAULT contract record at this head. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Contract reviewServed-tier: The face is the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha: What holds
MustNone. ShouldNone for this PR. One carrier is owed outside the diff: the ADR-0138 D2 note recording the new unauthenticated door, which the PR leaves to the seat because Nits
Gates70 check runs at this head (latest run of each): every one is success or skipped, none failed or pending. This includes Test Core 1–8/8, Test UI 1–16/16, Type Check UI, Lint UI, Build & E2E UI, Build Core, TypeScript Type Check, Lint & Repo Gates, Governed Surface Queue Guard and Check Changeset. The PR body records the plugin-auth suite (5668 passed) and typecheck at this head, and The TIER_DEFAULT contract record for the widening is comment 6910359938 (PASS), written in the same pass. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv 席位核对 · ACCEPT · Head-sha: 749c7a2 · 2026-11-16T07:38Z
|
Requested by Steedos · project thread
维护者速读
packages/plugins/plugin-auth/src/oauth-client-name.ts(新接口的放行条件)、oauth-callback-refusal-reason.ts(回调上带原因的条件)、ui/apps/console/src/pages/auth/LoginPage.tsx(登录页的两处读取)。pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/oauth-authorize-refusal.test.ts,预期 69 个测试全部通过。Fixes #34168
Clause-②: yes (widening)
Metadata-protocol: none
What changes
All four items of the card.
AuthManagerOptions.oidcAuthorizeGatemay answerOidcAuthorizeGateRefusal({ allowed: false, reason, message }) in place offalse. An object refuses only when it saysallowed: false; every other answer keeps the truthiness the gate was always read with, so nothing changes who is admitted.oauth-authorize-refusal.tsalready chooses between:403envelope keepscode: ENV_ACCESS_DENIED, gainsreason, and itsmessageis the host's sentence;redirect_urikeepserror=access_denied(RFC 6749 §4.1.2.1), sends the host's sentence aserror_description, and addsobjectstack_error_reason;[a-z_]{1,40}is dropped and the refusal stands. A sentence with a control character or an angle bracket, or longer than 300 characters, is replaced by the fixed sentence. On the redirect only, a sentence outside the character set RFC 6749 §4.1.2.1 allows forerror_description(printable ASCII without the double quote and the backslash) is also replaced by the fixed sentence.objectstack_error_reason. RFC 6749 §8.2 asks an extension parameter that is not registered to carry a vendor prefix, so it cannot collide with a registered name. The card's example,error_reason, is not free: some identity providers already send it with their own values.GET /callback/:id) rebuilds its error redirect fromerroranderror_descriptiononly. One after-hook,carryRefusalReasonOnCallback(oauth-callback-refusal-reason.ts, called fromauth-manager-after-hook.ts), puts the reason back on that redirect. It acts only when all of these hold: aGETof the platform identity provider's callback; the request's own query sayserror=access_deniedand carries exactly one reason of the validated shape; the callback answered a redirect whose query sayserror=access_deniedand carries no reason yet. The rest of the location is kept byte for byte. The organization's name is not a field anywhere: it travels only inside the host's sentence.ssoCallbackRefusalMessagetakes the reason:not_memberandinvitation_pendingget their own sentences, underaccess_deniedonly. An unknown reason, no reason, or a reason beside another error code keeps today's sentence. Three keys are added in all eleven packs (real translations; zh-Hant regenerated bygen:zh-hant):auth.login.errors.ssoAccessDeniedNotMember,auth.login.errors.ssoAccessDeniedInvitationPending,auth.login.ssoHandoffClient.GET /api/v1/auth/oauth2/client-name?client_id=CLIENT_ID&oauth_query=SIGNED_QUERY(oauth-client-name.ts, mounted inauth-plugin.ts, ledgered inauth-route-ledger.tsaspublic):oauth_querymust carry a signature this server made and that has not expired, checked by the provider's ownverifyOAuthQueryParams; the session is never read;client_idinside the verified request, and the URL'sclient_idmust equal it;{ client_name }and nothing else of the client;client_id, an unknown client, a disabled client and a client with no name all answer the same404; a parameter outside the closed set, a repeated one or a missing one answers400;429RATE_LIMIT_EXCEEDEDwithRetry-After.LoginPageasks it once on a signed hand-off and shows "Sign in to continue to NAME"; any other answer (refusal, network failure, another body shape, no signed request on the URL) keeps "Continue to HOST".redirect_urirule is unchanged: the redirect is followed exactly when it was before.Tests
packages/plugins/plugin-auth/src/oauth-authorize-refusal.test.ts, over the file's real-AuthManagerharness (real better-auth, the real oauth-provider):{ success: true, data: { client_name } }; a mismatchedclient_idis refused and the other client's name never appears; an unknown client, a disabled client, a signed request whoseclient_idwas changed, and an expired one each get the same refusal as a mismatch; three malformed requests answer400; the window's reads from one address answer, the next is refused with429,RATE_LIMIT_EXCEEDED,Retry-Afterandno-store, and another address still answers;AuthManagerwith the platform identity provider and a second one, fed the provider's real refusal parameters. The reason lands on/_console/loginbesideerroranderror_description; CONTROL: a boolean refusal lands with no reason; not carried for a reason of another shape, a reason beside another error, a reason from the other identity provider, or two reasons.auth-route-ledger.conformance.test.ts: the new route in the objectstack list.LoginPage.access-denied-32992.test.tsxgains a describe for the two reasons, an unknown reason and a reason beside another code. NewLoginPage.handoff-client-name-34168.test.tsx: the name is shown and asked with the URL's client and the whole signed request; the host line stays on a 404, a network failure and a body of another shape; CONTROL: no signed request, nothing asked.Ablations (each mutation landed on disk through scripts/ablation-replace.mjs; every restore read blob == HEAD and git diff HEAD empty; the subjects resolve from src, no build between legs)
fb0d4b052)client_idno longer has to equal the signed oneaccess_deniedchecks removed (request held, redirect ablated)749c7a2ca)Round 1 (items 1 and 2) ablations stand as reported there: reason pattern 6 failed, sentence markup 2, sentence length 1, RFC charset 1, object truthiness 1, page escape 1.
Acceptance notes
cacheservice when one is registered, as the signed-out invitation preview is (ADR-0121 D6). Over the limit it answers429RATE_LIMIT_EXCEEDEDwithRetry-AfterandCache-Control: no-store.docs/adr/**is outside this card's file surface, so that note is left to the seat.GETcallback. A provider that answers byform_postreachesPOST /callback/:id, which the vendor re-issues as aGETrebuilt from its own known fields, so the reason would not survive that hop. The platform identity provider answers by query redirect, so this path is not exercised today.OidcAuthorizeGateRefusaland the rest) are exported from their modules, not re-exported from the package index.packages/spec/src/**file is touched.Verification
Round 3 (
749c7a2ca) adds the rate limit and touches plugin-auth only, so the plugin-auth suite and typecheck were re-read there; the Console, i18n and derived-gate readings below are fromfb0d4b052, whoseui/tree is unchanged at749c7a2ca.plugin-auth suite and typecheck
pnpm --filter '@objectstack/plugin-auth^...' buildand the package's own build, underos-verify-lock:pnpm --filter @objectstack/plugin-auth testexit 0, Test Files 278 passed (278), Tests 5668 passed, 10 skipped.pnpm --filter @objectstack/plugin-auth typecheckexit 0: all three legs (tsc --noEmit,tsconfig.examples.json,check:test-typecheck: "OK — @objectstack/plugin-auth's test layer compiles").fb0d4b052the full workspace build (119 tasks) andpnpm check:dual-build-cjs-loadswere green; round 3 adds no export and no new file.Console and i18n
From
ui/:pnpm exec vitest runoverapps/console/src/pages/auth/,all-locales-key-parity,untranslated-identity-4376,en-zh-key-parityand the product-neutral ratchet: Test Files 39 passed (39), Tests 429 passed (429).turbo run type-check --filter=@object-ui/console: exit 0, 75 tasks successful.node scripts/check-i18n-en-drift.mjs: exit 0, "No en value changed in this range."Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackatfb0d4b052: 83 families, each run with stdin closed after the full build, reconciled with--ran(83 derived, 83 run). 82 exit 0, among thempnpm check:auth-mount-ledgerandpnpm check:dual-build-cjs-loads("123 published require entry point(s) across 72 package(s) load"). 1 NOT MEASURED:pnpm check:type-check-debtexit 3 (PREREQUISITE NOT MET: its own closure build did not get a turn on the shared verify lock), and two further locked tries timed out in the queue (exit 99); read from CI. PR-body gate:check-closing-keyword-parity --bodyon this body binds onlyFixes #34168.Merge-tree (throwaway bare clone, no merge driver)
git merge-tree --write-treeof749c7a2caagainstorigin/main(951eceeee): exit 0, no conflicted path. #34257 has no pushed branch, so there is nothing to probe against.Clause-② re-measured
yes (widening)holds: the gate option's return type widens, the envelope gains an optionalreason, the redirects gain an optional parameter, one public, rate-limited read route is added, and three i18n keys are added. Nothing narrows: a boolean answer is byte-identical, and every existing route answers as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv