Repository navigation
Commit 338ef35
fix(auth)!: a boot outside development mode retires what the development seed issued (#36699)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Nxmrq3P2eHj4WzMaPKLjA1)_
Fixes #35184
Supersedes #36311: this branch carries that PR's commits (head
`c1e7347cc1`, merged onto current `main`) and adds one hardening commit.
The card thread can push only its own branch, so the takeover lands
here.
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill states what a boot outside development mode
does to a seeded account's credentials. `skills/**` names the
development seed only as `os dev --seed-admin`
(`skills/objectstack-platform/references/operations.md`); checked at
`origin/main`.
## 维护者速读
- 用户能看到什么变化:不在开发模式的服务器每次启动、开始接请求之前,会结束开发种子建的管理员和演示账号在开发期拿到的会话、API key
和令牌,包括这些账号以别人身份开的会话;只针对仍是种子密码的这些账号,运维改过密码的账号和管理员自建的账号不受影响,开发模式下什么都不变。
- 为什么做:开发种子凭据加固的第三项(#34717 裁决里留作跟进的那一项):离开开发模式后,开发种子签发的东西不再继续起作用。
- 出错会怎样:拿开发库直接上生产的部署,这些账号的旧会话和 key 会失效,需要运维改密后重新登录、重新发
key;结束不干净时服务器拒绝启动并说明是哪些账号。
- 要你做什么:收窄类改动,L1/L2 之后由你合并。
## What changes
**The rule (ruling item 3 on #34717, the card's text): when a deployment
leaves development mode, nothing the development seed issued keeps
acting for an account that carries the development seed stamp.**
Development mode is `NODE_ENV=development` (`isDevelopmentMode`, the
predicate the #34717 refusals use). No switch.
From #36311 (unchanged, see that PR for the full account):
- `dev-seed-credential-retirement.ts` (new), `retireDevSeedCredentials`:
outside development mode, one indexed read for stamped accounts, the
in-force filter (`isDevSeedCredentialInForce`), then per account the
revocation `os user set-password` uses (`revokeSessionsAndApiKeys`:
sessions tombstoned, keys revoked, authorized apps, device sign-ins,
linked sign-in accounts, registered OAuth apps, SCIM credentials),
outstanding reset tokens (`endOutstandingResetTokens`), and sessions in
a host `secondaryStorage` (read back).
- Wiring: one `kernel:ready` hook in `auth-plugin.ts`, independent of
`registerRoutes`; it settles before `kernel:listening` opens the socket.
- Fail closed: anything that does not land fails the boot with one
sentence naming the accounts and the remedy.
- Docs (`content/docs/deployment/self-hosting.mdx`), changeset (`patch`,
`!`, BREAKING section, ADR-0087 `not-required`), census shard
regenerated.
New in this PR:
- **The sessions a seed account opened acting as another account are
retired too** (`retireSessionsOpenedAs`), tombstoned exactly as the
account's own (same reason, counted in `sessions`, same fail-closed
rule). A further security item is with the owner seat.
- `forced-reset-revocation.ts`: `isLiveSession` is exported for reuse
(no behaviour change).
- Docs and changeset name the new item; the self-hosting sentence about
`os user set-password` now says what that command ends (the account's
own sessions, keys and grants) instead of "the same credentials".
- Census shard regenerated on current `main` (`node
scripts/tenant-audit-census.mjs --write`).
**Read first (by risk):**
1. `packages/plugins/plugin-auth/src/dev-seed-credential-retirement.ts`:
`retireDevSeedCredentials` and `retireSessionsOpenedAs`.
2. `packages/plugins/plugin-auth/src/auth-plugin.ts`, the `kernel:ready`
hook: it runs on every boot outside development.
3.
`packages/plugins/plugin-auth/src/dev-seed-credential-retirement.test.ts`,
cases 1–3.
**Two-minute check:** `pnpm --filter @objectstack/plugin-auth exec
vitest run src/dev-seed-credential-retirement.test.ts` shows 6 cases
green.
## Why
#35184 (p1): credentials the development seed issued kept acting after
the deployment left development mode.
## Verification
Branch `claude/project-thread-grxa1f`, head `fb3c2cc478`, on
`origin/main` `115d38788e`.
- **Red first.** The new assertion was added to case 1 before the fix
and run at the merged head (`035b1fdfe`): case 1 red, 5 others green.
After the fix: 6/6 green. Removing the new call is that same red.
- **Suites** (under `scripts/pm/os-verify-lock.sh`):
`dev-seed-credential-retirement`, `dev-seed-credential-production`,
`dev-seed-credential` (3 files, 26 passed) on the port before the fix;
then `dev-seed-credential-retirement`, `api-key-restore-guard`,
`forced-reset-revoke-reason-vocabulary`,
`scim-deactivation-reconcile-user`, `session-tombstone`,
`admin-impersonate-endpoint` (6 files, 128 passed) after it. `pnpm
--filter @objectstack/plugin-auth build && … typecheck`: exit 0,
`check:test-typecheck` OK.
- **Derived gates:** `node scripts/pm/dispatch-gates.mjs --commands`
derived 110, all run: 104 exit 0; `check-empty-changeset` exit 1 by
design (the DELIBERATE CORRECTION below); `check-tenant-audit-census`
and its self-test exit 1 on the first pass (shard drift from the new
write site), regenerated, both re-run exit 0; NOT MEASURED (exit 3,
prerequisite): `check-plugin-teardown-shape --self-test` (needs an
unshallow clone), `check:skill-examples`, `check:dual-build-cjs-loads`
(need packages built). CI carries those three.
- **Overlap:** see Acceptance notes.
- **Dogfood battery:** not run locally for this round; CI's Dogfood
Regression Gate reads it. #36311's battery (484 files passed, 0 failed)
was on the code before the new commit.
## Acceptance notes
- **Which accounts.** The in-force reading from #36311 stands: an
account whose password was set since the seed holds a credential the
seed did not issue and is untouched; retiring on the bare column would
end operator-era credentials at every restart.
- **Revoke reason.** `admin_password_reset`, as in #36311; a dedicated
reason is follow-up #36313.
- **`.changeset/dev-seed-credential-production-refusal.md`**
(unreleased, from #34717) is corrected: see `## DELIBERATE CORRECTION`.
- **Test file weight.** The six two-boot cases read about 11.4 s of test
time locally (case 1 gained one sign-in and one request); #36311 read
9.98 s. Over the 10 s file line; splitting the file would duplicate its
two-boot harness, so it is kept as one and declared here.
- **Overlap** (`overlap-check.mjs` at this head, #36311 excluded):
`.changeset/dev-seed-credential-production-refusal.md` conflicts with
#35129; the generated census shard conflicts with #34738 (whoever lands
second regenerates it). `auth-plugin.ts` with #36690 merges cleanly.
- The production-readiness page is not edited; the card names the
self-hosting checklist.
## DELIBERATE CORRECTION
This PR rewrites two lines in a pending release note it did not add:
`.changeset/dev-seed-credential-production-refusal.md`, in the note's
last paragraph. That paragraph's label and its last sentence named the
boot-time retirement as a follow-up. This PR ships it, so left unchanged
the note would publish two false lines. `check-empty-changeset` stays
red by design; the dispatching seat confirms by its own record.
1. The paragraph's bold label
- Before: "**Not ended at boot:**"
- After: "**Ended by `os user set-password`, and at boot:**"
2. The paragraph's last sentence
- Before: "Ending them at boot is follow-up #35184."
- After: "In the same release, a boot outside development mode also
retires them: see the note "a boot outside development mode retires what
the development seed issued" (#36699)."
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is read from CI's Lint job, not
run locally.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01JQwxbX8ecPYZVemPRBFSrY
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e5213e7 commit 338ef35
8 files changed
Lines changed: 840 additions & 18 deletions
File tree
- .changeset
- content/docs/deployment
- docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
657 | 671 | | |
658 | 672 | | |
659 | 673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
1822 | 1823 | | |
1823 | 1824 | | |
1824 | 1825 | | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
1825 | 1843 | | |
1826 | 1844 | | |
1827 | 1845 | | |
| |||
0 commit comments