Repository navigation
fix(plugin-auth)!: a change to a user's credential ends every other outstanding password-reset token of that user - #34667
Conversation
…okens WIP: the seam module and its adapter wiring; tests follow. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…tokens at every door WIP: door-level pins, changeset and the docs line. 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>
…write site Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
The tenant-audit census conflict is resolved by regeneration over main's page: main's population plus this branch's one write site. 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>
📓 Docs Drift CheckThis PR changes 1 package(s): 21 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 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 e907aeae4071ba8f37f132fa7a1c494354a7cb9f && git checkout e907aeae4071ba8f37f132fa7a1c494354a7cb9f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin dc66d3308271f3055308c5c982ebc8d53195065f 1e66034e6aac09d97216eedebcc3a3f1490f27e8 && git checkout -B drift-repro dc66d3308271f3055308c5c982ebc8d53195065f && git merge --no-ff 1e66034e6aac09d97216eedebcc3a3f1490f27e8
node scripts/docs-audit/affected-docs.mjs --json dc66d3308271f3055308c5c982ebc8d53195065f
|
|
security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj The seat adopts the record below, rendered on this head by an isolated reviewer at the contract-review tier. The seat orders S1–S4 before landing. Contract reviewServed-tier: ① Derived judgmentsRead: the diff
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing against should-fix
nit
Implemented-by: VERDICT: PASS |
Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…s and refuses where it cannot find or name them WIP: predicate deletes where no cache is configured; pins for the composed identifier setting, the cache arm's refusal, the cached texted code, the administrator's door on a user with no local password and the raw adapter. 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>
…write sites Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…hat apply it Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
The tenant-audit census conflict is resolved by regeneration over main's sharded census: main's population plus this branch's three write sites, all in the plugin-auth shard. 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>
|
security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj The seat adopts the delta record below, rendered on this head by the same isolated reviewer at the contract-review tier. D1 is accepted as a declared deviation: that refusal is unreachable through the shipped composition, and the PR body states it. Contract reviewServed-tier: Delta record on my PASS at ① Derived judgmentsFindings of the prior record:
What I re-derived on this head:
② Semver levelUnchanged and still correct: ③ Boundary flags
④ Design judgmentThe code agrees with the narrowed, re-scoped claim. No must-fix. should-fix
nit
Implemented-by: VERDICT: PASS |
|
security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj 席位核对ACCEPT · head
|
Clause-②: no (narrowing) — a password write through either of this plugin's storage adapters (the factory
AuthManagercomposes, and the exported rawcreateObjectQLAdapter) ends every other password-reset link and texted reset code still outstanding for that user, in the same request and before the new password is written. In theAuthManagercomposition that is every door that sets a password: a completed reset (POST /reset-password,POST /phone-number/reset-password), the user's ownPOST /change-password, an administrator'sPOST /admin/set-user-password, and a first password (POST /set-initial-password). No request, response or metadata shape is added, removed or re-shaped; a link or code requested after the change resets as usual.Metadata-protocol: none
Skills-docs: updated here —
content/docs/permissions/authentication.mdxstates the rule; no skill underskills/**teaches the reset doors.维护者速读
createObjectQLAdapter),该用户此前发出、尚未使用的其他重置链接和短信重置码一律作废;改动之后再申请的链接/验证码照常可用。packages/plugins/plugin-auth/src/credential-change-ends-reset-tokens.ts(规则、两条删除路径与三种拒绝)、packages/plugins/plugin-auth/src/objectql-adapter.ts中工厂适配器与原始适配器的 create / update / updateMany 接线(均在写入之前)、packages/plugins/plugin-auth/src/credential-change-ends-reset-tokens.test.ts。pnpm --filter @objectstack/plugin-auth exec vitest run src/credential-change-ends-reset-tokens.test.ts,预期 17/17 通过。What changes
packages/plugins/plugin-auth/src/credential-change-ends-reset-tokens.ts(new): a change to a user's credential ends every other outstanding password-reset token of that user — the emailed reset links and the texted reset code for the phone number the user holds — and, with a hostsecondaryStoragein theAuthManagercomposition, their cached copies. An ended token answers exactly what a token never issued answers. With no cache, each token shape is ended by one predicate delete; with a cache, the links are read first so each cached copy can be named, and exactly those rows are deleted. A password write is refused, and the old password stands, when its tokens cannot be ended, when a cached link's key cannot be named, when the verification store keeps identifiers other than plain (verification.storeIdentifier), or when the account row it targets names no user.packages/plugins/plugin-auth/src/objectql-adapter.ts: both storage adapters call the rule for everysys_accountwrite that carriespassword, before the write lands: the factoryAuthManagercomposes (create,update,updateMany) and the exported rawcreateObjectQLAdapter(the same three verbs). The raw adapter is handed none of better-auth's options, so through it the rule covers the token rows only; a host that pairs it with asecondaryStorageor averification.storeIdentifiersetting is outside the rule.content/docs/permissions/authentication.mdxstates the rule beside the reset section.mainfor this change's three engine write sites (node scripts/tenant-audit-census.mjs --write);main's census is now sharded per package, so the only moved artefact is the plugin-auth shard (docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-auth.md): write call sites 95 → 98, object name chosen at run time 37 → 40, other run-time expression 35 → 38, provably carrying no context 12 → 15, readable engine type 69 → 72; repository total 325.@objectstack/plugin-authpatch, BREAKING narrowing, ADR-0087not-required; it scopes the rule to the two storage adapters and states what the raw one does not cover.The eight plugin-auth files held by #34333 are untouched.
Tests
packages/plugins/plugin-auth/src/credential-change-ends-reset-tokens.test.ts— every door through the real routes (a realAuthManagerover a realObjectQLengine on better-sqlite3, behindAuthPlugin.registerAuthRouteson a Hono app):POST /reset-passwordand at its landing (GET /reset-password/:token); the password is the one the spent link set;POST /change-password,POST /admin/set-user-password(for a user with a local password and for one without) andPOST /set-initial-passwordeach end every link outstanding before them; a link requested afterwards resets (the control);createObjectQLAdapterends the holder's earlier link;secondaryStoragecache, an ended link's and an ended texted code's cached copies are gone, and the link answers what a never-issued link answers;Acceptance notes
Verification
Head
1e66034e6a. The pins, the ablation, the suite, typecheck and the gates were read at5f08f64e63; the one commit after it,1e66034e6a, mergesmaincommits that touch onlyui/**and.changeset/**, and the census gate was re-run there.credential-change-ends-reset-tokens.test.ts: 17/17 passed.6aa9ab8204, the rule's entry point incredential-change-ends-reset-tokens.tsmade inert throughscripts/ablation-replace.mjs): 15 of 17 red, then restored — blob equal toHEAD,git diff HEADempty. The two that stay green are by design: the cross-user control, and the composed-configuration pin, which reads the auth instance and not the rule.pnpm --filter @objectstack/plugin-auth test: exit 0, Test Files 283 passed (283), Tests 5923 passed / 10 skipped (5933).pnpm --filter @objectstack/plugin-auth typecheck: exit 0 (includingcheck:test-typecheck, debt ledger unchanged).node scripts/check-tenant-audit-census.mjs: exit 0 at5f08f64e63and at1e66034e6a(325 write call sites certified across 18 package shards);--self-testexit 0.f389175cb7(478 passed / 3 skipped files) is the seam module, its wiring in both adapters, its pins, the changeset and the census.node scripts/pm/dispatch-gates.mjs --commands(100 families), each run with its exit code captured before any pipe, then--ranreconciled: 98 exit 0; 1 NOT MEASURED —pnpm check:dual-build-cjs-loadsexit 3 (prerequisite: a full repository build), left to CI; 1 exit 1 —pnpm check:docs-transcript-drift, on three pages this diff does not touch (content/docs/deployment/validating-metadata.mdx,content/docs/getting-started/build-with-claude-code.mdx,content/docs/ui/react-pages.mdx), whose stated author-time rule count is one above whatpackages/lint/src/authoring-rules.tsderives; this tree is byte-identical tomainon those pages and onpackages/lint, so the reading ismain's own.check:docs,check:skill-examplesandcheck:type-check-debtwere re-run after their prerequisite builds: exit 0 each.Gate readings
node scripts/check-tenant-audit-census.mjs: exit 0 — 325 write call sites certified across 18 package shards.pnpm --filter @objectstack/spec run check:docs: exit 0 — 248 generated files in sync.pnpm --filter @objectstack/spec run check:skill-examples: exit 0 — 347 prose examples type-check across 3 surfaces.pnpm check:type-check-debt: exit 0 — 0 raw tsc errors above any recorded number.pnpm check:nul-bytes: exit 0 at1e66034e6a.node scripts/pm/dispatch-gates.mjs --ran: 100 derived families accounted for — 99 run, 1 NOT MEASURED.Generated by Claude Code