Repository navigation
Commit b3247dd
fix(auth)!: a server outside development mode refuses a development seed credential (#34717)
Clause-②: yes (narrowing)
Metadata-protocol: none
## 维护者速读
- 改了什么:不在开发模式(`NODE_ENV` 不是
`development`)的服务器不再接受开发种子凭据:用开发种子密码(`admin123`,或
`OS_SEED_ADMIN_PASSWORD` 的值)登录一律拒绝;`os dev` 种出的管理员和 `demoStaff`
账号(只有走种子自身开通票据的创建)带种子标记,管理员建的账号不带,密码仍是种子密码时任何登录方式都不开会话。新增 `os user
set-password EMAIL`,在服务器上直接改密码,拒绝提示里点名它。本 PR 只落裁决第 1、2 项。
- 为什么改:维护者裁决(选项 A):不在开发模式的服务器永不接受开发种子凭据;拒绝放在 plugin-auth,`os start`、`os
serve`、镜像与自定义宿主一并覆盖。维护者续裁:「已经开发完的要继续跟进到合并」「只合前两项:第三项另开一张跟进卡。」
- 风险与回滚:生产模式下凡是密码等于开发种子密码的账号都登不进去,需运维用新命令改密;开发模式不变。离开开发模式前已签发的会话与 API
key 由 `os user set-password` 结束,开机时结束它们是 #35184。生产模式每次建会话多一次 `sys_user`
读。回滚即 revert 本 PR(新列留空无害)。
-
先看:`packages/plugins/plugin-auth/src/dev-seed-credential.ts`(三条拒绝与种子标记)、`auth-manager-membership-admission.ts`(种子标记只在种子开通票据被证实时暂存)、`operator-password-reset.ts`(改密:先清掉该账号未用的重置令牌,再写密码、撤会话与
API key)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/dev-seed-credential-production.test.ts`,应见 13
个用例全绿(含管理员建号对照组:开发模式建、生产模式能登录)。
- 需要你做的:无,席位落地(a security item is with the owner seat)。
## What changes
**The rule: a server that is not in development mode never accepts a
development seed credential.** Development mode is
`NODE_ENV=development`, the condition the development seed itself runs
under. The rule lives in `@objectstack/plugin-auth`, so `os start`, `os
serve`, the image and a custom host all apply it. This PR lands ruling
items 1 and 2.
- **The seed password is refused at sign-in, on any account**
(`refuseDevSeedPasswordSignIn`, first in the global `hooks.before`). A
password sign-in (`/sign-in/email`, `/sign-in/username`,
`/sign-in/phone-number`) that submits the development seed password
(`admin123`, or the value `OS_SEED_ADMIN_PASSWORD` sets) answers `403
PERMISSION_DENIED` with a sentence naming `os user set-password EMAIL`.
It is decided on the submitted password alone, so every address gets the
same answer.
- **The verifier never accepts a seed credential**
(`withDevSeedPasswordRefusal`, wrapping the pair handed to
`emailAndPassword.password`): a seed password, or the hash a marked
account still holds from the seed, is answered as a wrong password on
every door that checks a password.
- **The seed mark.** `sys_user.dev_seed_credential` (new, `internal`,
`readonly`, indexed, translated in all locales) holds a SHA-256 digest
of the password hash the seed stored, never the password. It is staged
by the audience gate only for a creation that proved the development
seed's own provisioning ticket for its address (`os dev`'s admin, each
`demoStaff` account), never for the wider operator class (an
administrator's create-user, a bulk import, directory provisioning), and
written in `account.create.after`, in development only. Any password
change stops it matching.
- **A marked account still on its seed password opens no session**
(`refuseDevSeedCredentialSession`, in `session.create.before`), on every
door: password, emailed link, one-time code, passkey, social or SSO,
impersonation and a minted session. The answer is `403
PERMISSION_DENIED` naming the reset command; a read that fails answers
`503`, as the sibling refusals do.
- **No forced change at sign-in.** No refusal opens a session in which
the password could be changed.
- **`os user set-password EMAIL`** (new `user` topic). It resolves the
account first, reads the password from an unechoed prompt (twice) or
`--password-stdin`, never from argv. plugin-auth's `setOperatorPassword`
checks exactly two things about the new password, that it is not a seed
password and that it is 8 to 128 characters (the deployment's own
password policy and history are not applied), refuses an account with no
password credential, deletes the account's outstanding password-reset
rows before the new password lands (the rule every password door keeps,
`credential-change-ends-reset-tokens.ts`), writes better-auth's own
hash, clears the mark and any sign-in lock, stamps
`password_changed_at`, and ends every session and revokes every API key
of the account (`revokeSessionsAndApiKeys`). It sets no forced change.
It writes the project database only: a host secondary storage is out of
its reach for reset links and sessions alike, and the docs give the
remedy (run it with the server stopped, or restart the server
afterwards).
- Docs: `content/docs/deployment/cli.mdx` (the command),
`content/docs/deployment/self-hosting.mdx` (the rule). Changeset:
`.changeset/dev-seed-credential-production-refusal.md` (BREAKING banner,
`Clause-②`, ADR-0087 `not-required` marker naming the added system
column). Both the changeset and `self-hosting.mdx` state the release's
present limit: sessions and API keys a seeded account was issued before
the server left development mode are ended by `os user set-password`,
and ending them at boot is follow-up #35184.
## Tests
-
`packages/plugins/plugin-auth/src/dev-seed-credential-production.test.ts`
(13; real `ObjectKernel` + ObjectQL on SQLite + `AuthPlugin` with one
`demoStaff` entry + `SecurityPlugin`, seeded in development, then served
by a second `AuthManager` outside development): development control; an
account an administrator creates in development (better-auth
`createUser`, as `/admin/create-user` drives it) carries no mark while
the seed's accounts on the same boot do, and it signs in outside
development mode; the mark is a digest and never served; the seed admin
refused 403 with the command and no session; a demo account refused; the
phone-number password sign-in refused; an unknown address answered
identically; an unmarked account on the seed password refused; a marked
account on a custom seed password answered as a wrong password with no
session; the emailed sign-in link opens no session for it; after
`setOperatorPassword` the new password signs in, the mark is gone and
the development session is ended; the reset ends the account's
outstanding reset links and no other account's; the reset's refusals
write nothing.
- `packages/plugins/plugin-auth/src/dev-seed-credential.test.ts` (7,
unit): the seed password set, the sign-in refusal's doors and
development passthrough, the verifier's answers. `/sign-in/username`
stays in the refused set but has no real-pipeline case: the platform's
own composition serves no username plugin.
- `packages/cli/src/commands/user/set-password.integration.test.ts` (3,
real SQLite file through oclif): sets the password from stdin in the
format a server verifies and ends the session and the API key; refuses
the seed password and writes nothing; refuses an unknown address before
asking.
-
`packages/cli/src/utils/schema-migrate.one-shot-family.integration.test.ts`:
the command joins the one-shot family.
- `packages/cli/test/dev-start-shared-data-key.integration.test.ts`: the
fixture serves an `os dev` database under `os start`, so it now runs `os
user set-password` between the two boots and signs in with the password
it set. Its assertions are unchanged.
- `packages/qa/dogfood/test/colleague-lookup-over-mcp.dogfood.test.ts`:
the directory set leaves out an `internal` column served to nobody.
## Acceptance notes
- Ruling item 3 is follow-up card #35184; this PR lands items 1–2.
- `origin/main` merged at `4b1eb0eab7` (220 first-parent commits).
Conflicts: `auth-manager-membership-admission.ts` kept both sides (the
seed mark staging, then main's invitation-admission staging); the two
tenant-audit census files took main's version and the plugin-auth shard
was regenerated with `node scripts/tenant-audit-census.mjs --write`.
- After the merge, `setOperatorPassword` also keeps main's rule that a
password set ends the account's outstanding reset tokens. It deletes the
rows in the project database before the write; a host `secondaryStorage`
is not reachable from the CLI, the same reach as the raw adapter
(`createObjectQLAdapter`), and the docs and changeset state that reach.
- A database seeded before this release with a custom seed password
carries no mark and is not detected; the changeset says so.
## Verification
Tree `objectstack-ai/objectstack`, branch `claude/sec2-gpr7`, final head
`cc6754e708`. Each reading names its commit; the last round
(`222a618930` to `cc6754e708`) touched plugin-auth source and tests, two
docs pages and the changeset only.
<details><summary>Suites (under scripts/pm/os-verify-lock.sh)</summary>
- `pnpm --filter @objectstack/plugin-auth build && pnpm --filter
@objectstack/plugin-auth exec vitest run --maxWorkers=2 && pnpm --filter
@objectstack/plugin-auth typecheck` on `cc6754e708`: 287 files passed;
6017 passed, 10 skipped; typecheck exit 0.
- Seed suites on `cc6754e708` (`dev-seed-credential-production`,
`dev-seed-credential`): 20 passed.
- `pnpm --filter @objectstack/platform-objects exec vitest run
--maxWorkers=2` on `16228898f8`: 123 files, 2047 passed.
- `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2` on `16228898f8`: 428 files, 6098 passed.
- `--project integration`, the set-password suite and the one-shot
family: 2 files, 182 passed.
`test/dev-start-shared-data-key.integration.test.ts` on `222a618930`: 6
passed. The rest of the integration layer is declared to CI (`Test
Core`, green on `cc6754e708`).
- Seed suites plus `first-session-membership-ordering` and
`credential-change-ends-reset-tokens` on `6d75801d76`: 4 files, 55
passed.
</details>
<details><summary>Ablation (each mutation red, then restored)</summary>
On `cc6754e708`, against `dev-seed-credential-production.test.ts` (13
tests), one leg per wiring point, each through
`scripts/ablation-replace.mjs` with the blob equal to HEAD and `git diff
HEAD` empty after the restore: sign-in refusal 4 red; verifier 1 red;
session refusal 1 red; mark staging removed 6 red; mark staged on the
operator class instead of the proven ticket 1 red (the
administrator-created control); reset-token end in the operator reset 1
red. Control: 13 of 13.
</details>
<details><summary>Type check</summary>
- `turbo run typecheck --filter='...@objectstack/plugin-auth'
--filter='...@objectstack/platform-objects'
--filter='...@objectstack/cli' --concurrency=2` on `6178523ef4`: 158 of
158 tasks successful. On `cc6754e708`, `TypeScript Type Check` is green
in CI.
- `pnpm --filter @objectstack/cli typecheck && pnpm --filter
@objectstack/plugin-auth typecheck` on `222a618930`: exit 0. plugin-auth
typecheck on `cc6754e708`: exit 0.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `222a618930`: 125 families. 125 exited 0
(`check:type-check-debt` exited 3 while the verify lock was held and 0
on a retry). `--ran`: 125 derived, 125 run, 0 NOT MEASURED.
`check:tenant-audit-census` and `check:cli-test-child-env` exit 0. On
`cc6754e708` the derivation is the same 125 families; the 102 that read
the last round's seven files were re-run, all exit 0, and `--ran` reads
102 derived, 102 run, 0 NOT MEASURED.
</details>
<details><summary>Dogfood battery</summary>
`pnpm --filter @objectstack/dogfood test` on `222a618930` (the last
round moves no door-level assertion, so it was not re-run): 483 files,
480 passed, 3 skipped; 4143 tests, 4075 passed, 68 skipped, 0 failed.
</details>
<details><summary>CI on cc6754e</summary>
All required contexts green: `Lint & Repo Gates`, `TypeScript Type
Check`, `Test Core` (10 of 10 shards), `Build Core`, `Governed Surface
Queue Guard`, `Live E2E UI`, `Test UI`, `Dogfood Regression Gate`; `Lint
UI`, `Type Check UI`, `Build & E2E UI` skipped by their selectors. 41
success, 15 skipped, 0 failed.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj)_
<!-- signed: security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 4b6d104 commit b3247dd
32 files changed
Lines changed: 1812 additions & 53 deletions
File tree
- .changeset
- content/docs/deployment
- docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins
- packages
- cli
- src
- commands/user
- utils
- test
- platform-objects/src
- apps/translations
- identity
- plugins/plugin-auth/src
- qa/dogfood/test
| 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 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
857 | 898 | | |
858 | 899 | | |
859 | 900 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
620 | 634 | | |
621 | 635 | | |
622 | 636 | | |
| |||
| 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 | 22 | | |
23 | | - | |
| 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 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
0 commit comments