Repository navigation
fix(plugin-auth): a session a password reset ends leaves a revocation trail - #29921
Conversation
…n trail Pins, per reset door at the plugin harness, that every session the account held is still a sys_session row after a completed reset, stamped revoked_at and revoke_reason password_reset, and still answers 401; the control is an administrator's forced reset, which stamps admin_password_reset. The ledger tests name every reset door. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
… trail Every reset door (/reset-password, /phone-number/reset-password, and the email-OTP door on its own path) joins the interactive-revoke ledger with the value password_reset, so a session a completed reset ends is stamped in place (revoked_at, revoke_reason) instead of deleted, and stays refused. The value differs from the forced reset's admin_password_reset. sys_session.revoke_reason's published vocabulary names it. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…w says what a reset leaves 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>
…not mount it Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 5 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 — 23 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 9194786f3109a91c1c18b46ad15646a7002350c4 && git checkout 9194786f3109a91c1c18b46ad15646a7002350c4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a04e9d76c13363280bdd86950603f0e0e6deb6dd c8b82289a52972a6de3527192d8ae194f806f600 && git checkout -B drift-repro a04e9d76c13363280bdd86950603f0e0e6deb6dd && git merge --no-ff c8b82289a52972a6de3527192d8ae194f806f600
node scripts/docs-audit/affected-docs.mjs --json a04e9d76c13363280bdd86950603f0e0e6deb6dd
|
|
security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj 席位核对ACCEPT · head
|
Clause-②: no
Metadata-protocol: none
维护者速读
revoked_at与revoke_reason: password_reset,与交互式撤销会话留下的记录同类;该会话照旧被拒(401)。admin_password_reset不同,从记录即可分辨是谁结束了会话。sys_session已有的保留方式),不改变哪些会话被结束,不撤销 API key,不写logout审计行。回滚 = 还原本 PR,无数据迁移。packages/plugins/plugin-auth/src/session-tombstone.ts(INTERACTIVE_REVOKE_REASON新增三行重置入口)、packages/plugins/plugin-auth/src/password-reset-ends-sessions.test.ts(新增的 describe)、packages/platform-objects/src/identity/sys-session.object.ts(revoke_reason说明里的取值)。pnpm --filter @objectstack/plugin-auth exec vitest run src/password-reset-ends-sessions.test.ts,预期全部通过,其中 "a session a password reset ends leaves a revocation trail" 下三个用例通过。What changes
A session a password reset ends leaves a revocation trail.
INTERACTIVE_REVOKE_REASON(plugin-auth/src/session-tombstone.ts) gains every reset door with the valuepassword_reset:/reset-password(the emailed link),/phone-number/reset-password(the phone OTP reset), and/email-otp/reset-password(better-auth's email-OTP reset door, on its own path; the platform does not mount that plugin today, so the entry is keyed on the plugin's declared path and pinned against it). A completed reset now keeps each session row it ends, stampedexpires_ata second in the past,revoked_at, andrevoke_reason: password_reset, instead of deleting it; the session is still refused.user_revoked(the owner revoking their own sessions) and fromadmin_password_reset, which an administrator's forced reset keeps writing itself (forced-reset-revocation.ts, not through this ledger), so the row still says who ended the session. The ledger's docblock and thepassword-reset-ends-sessions.tsheader now say what is true.SESSION_ERASURE_PATHS, so their tombstones stay hidden from better-auth's session reads like every other.sys_session.revoke_reason's description, the field's published vocabulary, namespassword_reset(platform-objects), with the four translated help strings (enregenerated,zh-CN/ja-JP/es-EShand-written values extended the same way).docs/HARDENING.md: the session table's revocation row said the reset path deletes the row; it now says sign-out deletes, and a revoke or a completed reset keeps the row stamped.logoutaudit row is written.Tests
password-reset-ends-sessions.test.ts, new top-level describe "a session a password reset ends leaves a revocation trail", over the file's existing real-engine harness (AuthManager.handleRequest,ObjectQLover better-sqlite3):password_reset, and the session still answers 401UNAUTHENTICATED;runAdminSetUserPassword, with the depsauth-plugin.tshands it, over the same engine) still stampsadmin_password_reset.session-tombstone.test.ts: every reset door recordspassword_reset, and no ledger route writes the forced reset's value; the mounted-route check now also reads the phone-number family off a manager that mounts it; the email-OTP door is pinned to the vendor plugin's declared path, with a tripwire that it is not mounted today.forced-reset-revoke-reason-vocabulary.test.ts: the published vocabulary names every value the interactive-revoke ledger writes.Acceptance notes
resetCredentialPasswordcallsinternalAdapter.deleteUserSessions, which with nosecondaryStorageisdeleteManyWithHooks, which calls this adapter'sdeleteManyinside the endpoint's context; outside a SCIM request the adapter'stransactionhands the callback this same adapter. The two door tests are the measurement./change-passwordwithrevokeOtherSessionsamong them. Not touched; the ruling covers the reset doors only.Verification
All readings below are on head
c8b82289a5(the branch withorigin/mainmerged), unless a line names another commit. Heavy runs went throughscripts/pm/os-verify-lock.shon a shared box.Tests: targeted, full suites, typecheck
pnpm install --frozen-lockfileexit 0; closure build (turbo run buildover plugin-auth, platform-objects, the CLI and the i18n gate's packages) exit 0;pnpm --filter @objectstack/spec check:generatedexit 0, "All 14 generated artifacts are up to date".pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/password-reset-ends-sessions.test.ts src/session-tombstone.test.ts src/forced-reset-revoke-reason-vocabulary.test.tsexit 0, Test Files 3 passed (3), Tests 34 passed (34).@objectstack/plugin-authfull suite (vitest run --maxWorkers=2): exit 0, Test Files 219 passed (219), Tests 3766 passed, 10 skipped (3776).pnpm --filter @objectstack/plugin-auth typecheck: exit 0 (check:test-typecheck OK, ledger held).@objectstack/platform-objectssuite: exit 0, Test Files 110 passed (110), Tests 1512 passed (1512); itstypecheck: exit 0.78fd3bcf11.One-shot ablation (on 78fd3bc)
Mutation: the three reset-door rows taken back out of
INTERACTIVE_REVOKE_REASON(the ledger asorigin/mainhas it), throughscripts/ablation-replace.mjs(anchor hit 1 time, blob 7d3ba6a6d90b to d138b54ac6d4;'password_reset'rows on disk 3 to 0). The subject is imported fromsrc/by relative path, so no build sits between the mutation and the run.kept: false), the ledger's reset-door test, and the vocabulary test. The forced-reset control stayed green.git checkout HEAD --on the absolute path, blob back to 7d3ba6a6d90b equal to HEAD,git diff HEADempty, rows on disk 3.Derived gates (dispatch-gates, 64 commands)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 64 commands, every one run onc8b82289a5with its exit code captured before any pipe. 62 exit 0, includingpnpm check:i18n("all bundles in sync": the hand-writtenenhelp string matches the generator's output) andpnpm check:engine-double-contract.--ranreconciliation: 64 derived, 62 run, 2 NOT-MEASURED, 0 UNRUN.pnpm check:dual-build-cjs-loads, reason: exit 3, PREREQUISITE NOT MET, it reads the built output of every workspace package and 10 have nodist/in this worktree. CI's Lint & Repo Gates runs it.pnpm check:type-check-debt, reason: exit 3, its re-measure build never got a turn on the shared verify lock (another session's full dogfood run held it). Both changed packages' owntypecheck(test layer included) is green above. CI runs the gate.Generated by Claude Code