Skip to content

Commit e0670b9

Browse files
fix(platform-objects): offer Unlock Account and Set Password without the better-auth admin plugin (#34124)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi95Ria7nkoYHNufdhAbPptHq)_ Fixes #34010 Fixes #34130 Waits-on: #34119 (merged as 41ff7c3; this branch merged `origin/main` in round 3) Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:Setup → 用户里的「解锁账号」(`unlock_user`)和「设置密码」(`set_user_password`)去掉了 `requiresFeature: 'admin'`。没开 better-auth admin 插件的环境现在也会显示这两个按钮:解锁对被锁定的账号显示(自托管默认、托管的 Free/Team 环境都适用);设置密码只在非托管环境显示,托管环境仍按原规则隐藏。规格里 admin 特性的门禁登记表同步去掉这两项;`features.admin` 的说明文字、插件列表注释和认证文档里「这些操作需要 admin 插件」的旧说法一并改正(只有建用户、批量导入用户真正需要插件)。 - 为什么改:实测证明两个接口都不依赖 admin 插件。插件关时,连续输错密码锁住的账号,经管理员调用 `admin/unlock-user` 后锁定清除、可正常登录;管理员调用 `admin/set-user-password` 返回 200,成员可用新密码登录、旧密码失效;非管理员调用都被 403 拒绝。但按钮仍要求 admin 插件才显示,管理员在这些环境里无法在界面上解锁或重设密码。 - 风险与回滚:只改显示条件,接口、权限(`requiredPermissions`)、平台管理员身份判断,以及解锁「有锁定或开了两步验证才显示」、设置密码「托管环境隐藏」的规则都不变;建用户、模拟登录仍保持 admin 插件门控。回滚即还原这一个 PR。 - 先看:`packages/platform-objects/src/identity/sys-user.object.ts`(两处删除与块头注释)、`packages/spec/src/kernel/public-auth-features.ts`(登记表去掉两项)、`packages/plugins/plugin-auth/src/pending-sso-users.test.ts`(两组新的实跑钉子)、`content/docs/permissions/authentication.mdx`(标题与路由说明)。 - 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run src/pending-sso-users.test.ts -t "34010|34130"`,预期 7 个用例全绿(解锁:未托管、托管各一次实跑加插件开对照;设置密码:未托管实跑、按对话框默认值实跑、托管仍隐藏、插件开对照)。 - 需要你做的:无,席位落地。 ## What changes - `sys_user.unlock_user` drops `requiresFeature: 'admin'`. Its `visible` predicate (the platform-admin standing, then a row with a lock stamp or two-factor enabled) and `requiredPermissions` are unchanged. - #34130 (round 2): `sys_user.set_user_password` drops `requiresFeature: 'admin'` too. Its `visible` (the platform-admin standing and `features.cloudManaged != true`) and `requiredPermissions` are unchanged, so it stays hidden on a cloud-managed environment, whose door refuses every target. The card also asked to keep it hidden "for non-local accounts, as today": the predicate carries no identity-source rule today, so there is none to keep; the door's own refusals (a pending person `409`, SSO-only mode) are unchanged. - `PUBLIC_AUTH_FEATURES.admin.gatedInputs` (`packages/spec/src/kernel/public-auth-features.ts`) no longer books `sys_user.actions.unlock_user` or `sys_user.actions.set_user_password`; `admin` keeps `create_user` and `impersonate_user`. Forced, as on #33989: `feature-gate-guard.test.ts` holds the registry and the lowered predicates in lockstep, and its forward walk reds a booked input without the gate (seen in the ablation below). - The admin block header in `sys-user.object.ts`, record 6897296837's nits: - N1: the "buttons that 404" rationale no longer names `unlock_user`. It now names the two actions that keep the gate (`create_user`, `impersonate_user`), and the Ban / Unban paragraph becomes Ban / Unban / Unlock / Set Password, with the measured reasons (the lockout is plugin-auth's own, ADR-0069 D2, and the unlock clears it through the data engine; the password is written through better-auth's core `internalAdapter`). - N2: an expired `banned` is cleared at the next sign-in by better-auth's admin plugin where it is mounted, and by plugin-auth's `user-session-admission.ts` where it is not. The orphaned quote N2 named in `sys-user-set-manager-action.test.ts` ("only wired when `auth.plugins.admin` is enabled") is reworded to what the header says now. - Round 3 (after #34119 merged), the stale "needs the admin plugin" copies, record 6902922670's nits: - `features.admin` describe (`packages/spec/src/api/auth-endpoints.zod.ts`, `AuthFeaturesConfigSchema`): its second sentence said the console still shows unlock and set-password only when the flag is true. It now says banning, unbanning, unlocking and setting a password answer without the plugin, and whether the console offers those actions does not depend on the flag. `content/docs/references/api/auth-endpoints.mdx` regenerated (`check:generated --fix`). - `plugins.admin` describe (`packages/spec/src/system/auth-config.zod.ts`): read against main, it carries no console-button sentence (it already says ban/unban, unlock and set-password are served without the plugin), so it is unchanged. - `packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts`: comment only. It booked ban/unban and set-password on the vendor admin plugin; it now names what the plugin carries (what create-user and import-users drive, impersonation, better-auth's own `/admin/*` routes) and says ban/unban, unlock and set-password are ObjectStack mounts served with or without it. - `content/docs/permissions/authentication.mdx`: the "Admin User Management (requires `plugins.admin`; …)" heading becomes "Admin User Management (platform-admin gated)"; its exceptions line now says `create-user` and `import-users` need `plugins.admin` (`501 NOT_IMPLEMENTED` without it, `admin-user-endpoints.ts` / `admin-import-users.ts`) and `set-user-password`, `unlock-user`, `ban-user`, `unban-user`, `add-sso-user`, `import-sso-users` answer with or without it; the earlier paragraph no longer puts Set Password behind `plugins: { admin: true }`. - N1: the `set_user_password` `visible` comment no longer says the server keeps answering on an `env_native` row; it says the door refuses every target on a cloud-managed environment (`cloud-managed.ts`). - N2: `34010-unlock-without-admin-plugin.md` and this body carry plain `Clause-②: no` / `Metadata-protocol: none`. - N4: a new pin drives Set Password with the dialog's declared defaults (`mustChangePassword: true`, `revokeSessionsAndKeys: true`) on a kernel without the plugin (below). - N5: the `actions.mdx` `ban_user` example was already replaced on main by #34119 (it now shows `impersonate_user`); nothing to change here. - N3, measured fact, not changed here (the seat files it): in SSO-only mode `set_user_password` is offered on an `idp_provisioned` row, but the door refuses that target (`admin-user-endpoints.ts`, the `judgeSsoOnlyLocalPassword` check around line 1171). Read from code: the action's `visible` carries no identity-source term and the door does; no run here exercised SSO-only mode. - Root changesets, one per card: `34010-unlock-without-admin-plugin.md` and `34130-set-password-without-admin-plugin.md`, each `@objectstack/platform-objects` patch and `@objectstack/spec` patch, each carrying `Clause-②: no` / `Metadata-protocol: none`. The 34130 note also records the `features.admin` describe correction. ## Why (measured first) The card asked whether `POST /api/v1/auth/admin/unlock-user` unlocks a locked user end to end with the better-auth admin plugin off. Measured at 8ec7d2c (the live pin below, gate still in place), on a real `AuthManager` behind `AuthPlugin.registerAuthRoutes` with `plugins.admin: false` and `lockoutThreshold: 3`, unmanaged and managed: - three wrong passwords through the real `/sign-in/email` stamp `sys_user.locked_until` in the future, and the right password is then refused `401` with no new session; - the declared action's `visible` evaluated under the features that kernel serves (`features.admin === false`) answers `false`: hidden (`expected false to be true` at the offer, 2 failed); - with that one assertion removed for a measure-only run (restored from HEAD afterwards, `git diff HEAD` empty), the rest passed for both kernels (3 passed): a caller without the standing gets `403 PERMISSION_DENIED` and the lock stays; the platform admin posting what the action posts (`userId` from `recordIdParam`) gets `200`, `locked_until` reads null, `failed_login_count` 0; the next sign-in with the right password is `200`. So the door works without the plugin, and only the offer was missing. Regrade note for the seat: by the triage comment's own rule (p2 if it works without the plugin, same reach as #33759), this measured as p2. Round 2, #34130, measured at 25f44ac (its live pin, gate still in place), `plugins.admin: false`: on an unmanaged kernel the declared `set_user_password` is hidden (`expected false to be true` at the offer, 1 failed, 2 passed). With that assertion removed for a measure-only run (restored from HEAD, `git diff HEAD` empty), 3 passed: a caller without the standing gets `403 PERMISSION_DENIED` and the new password does not sign in; the platform admin posting what the action posts (its `bodyExtra`, `userId`, `newPassword`, `mustChangePassword: false`, `revokeSessionsAndKeys: false`) gets `200`; the member then signs in with the new password (`200`) and not with the old one (`401`). On a managed kernel the action stays hidden by its `cloudManaged` rule. ### Clause-② reading Same reading as record 6897296837 gave #33989 (its N4: "the answer is `no`"). No door or accepted input moves: `admin/unlock-user` was already mounted unconditionally (`auth-plugin.ts`, read only; it is held by #34050 and this PR does not touch it), and nothing server-side reads `visible`. `PUBLIC_AUTH_FEATURES` keeps its name and entry shape; `admin.gatedInputs` loses one string, so its `as const` tuple loses one member. Readers of `gatedInputs` are the same two tests #33989 listed. `check:api-surface` and `check:generated` are green. ## Tests - `plugin-auth/src/pending-sso-users.test.ts`, new top-level describe `[#34010] Unlock is offered and works without the admin plugin` in the existing shared harness: for an unmanaged and a managed kernel with `plugins.admin: false`, lock the member through the sign-in lockout, show the lock holding, judge the DECLARED `unlock_user` offered under `getPublicConfig().features`, show the door refusing a caller without the standing, post the action's call as the platform admin, read the row cleared and sign in. CONTROL: with the plugin on, the same flow is offered and works. - Harness edits: `stage()` takes an optional `config` merged into the manager (for `lockoutThreshold`); the #33759 describe's `ADMIN_PRINCIPAL` / `declaredAction` / `offeredOn` / `actionCall` move to module scope unchanged so both describes share them. - `plugin-auth/src/pending-sso-users.test.ts`, round 2, new top-level describe `[#34130] Set Password is offered and works without the admin plugin`: unmanaged, `plugins.admin: false`: the DECLARED action is offered, a caller without the standing is refused `403 PERMISSION_DENIED`, the admin's call answers `200`, and the member signs in with the new password and not the old; managed: it stays hidden (its `cloudManaged` rule); CONTROL: with the plugin on it is offered and sets the password. The shared `actionCall` now also sends the action's constant `bodyExtra`, as the console does (ban / unban / unlock declare none). - Round 3 (N4): `unmanaged kernel: with the dialog defaults the door also flags the member and revokes their sessions`. It reads the declared params' defaults (asserted to be exactly `mustChangePassword: true`, `revokeSessionsAndKeys: true`), posts them with the new password as the admin, and reads `200` with `data.mustChangePassword` and `data.revokeSessionsAndKeys` true and `revoked.complete` true, `sys_user.must_change_password` true, every member `sys_session` row stamped `revoke_reason: admin_password_reset` and expired (count equal to `revoked.sessions`), and the new password signing in. - `platform-objects/src/identity/action-state-visibility.test.ts`: the #33759 describe becomes `sys_user Ban / Unban / Unlock / Set Password are offered without the admin plugin`, with an Unlock case (a locked or two-factor row offered, one with neither not, managed or not), a Set Password case (offered unmanaged, hidden managed) and the standing leg for both. - Forced test edits: - `action-state-visibility.test.ts`: `unlock_user` and `set_user_password` leave the CONTROL roster `PLUGIN_ONLY` (exactly `create_user` and `impersonate_user` still read `features.admin`). - `platform-objects.test.ts`: the `feature-gate-lowering matrix (#2874)` rows for `unlock_user` and `set_user_password` now pin the bare predicates. - `identity/cloud-managed-visibility.test.ts`: its "keeps its other flag" case now runs over the five doors that carry another flag; `set_user_password` gets its own case (offered with `admin` off and `cloudManaged` off, hidden with `cloudManaged` on), and the header says why. - `sys-user-set-manager-action.test.ts`: comment only (N2's orphaned quote). ## Acceptance notes - #34119 merged (41ff7c3); round 3 merged `origin/main` (029cfa7) and then made the describe, comment and doc corrections above, as the claim amendment 6903911896 widened the file surface. - The scope-addition comment 6900996719 on #34130: all three stale copies it named (the `sys-user.object.ts` block header, the `auth-manager-plugin-list.ts` comment, the `authentication.mdx` heading) are corrected here; its N4 (no committed test drives `unlock-user` or `set-user-password` with `plugins.admin` off) is met by the live pins. - Not touched: `packages/plugins/plugin-auth/src/auth-plugin.ts` (held by #34050); `ui/**`. ## Verification Round 1 commits: 8ec7d2c adds the live pin (gate untouched; the measurement ran there); 665d71a drops the gate, books it, rewrites the header and the offer pins, and adds the changeset; f50eb24 only copies the claim's two declaration lines verbatim into the changeset. Round 2 (#34130): 25f44ac adds the Set Password live pin (measurement ran there); 3853d2c drops the gate and its booking and updates the header and offer pins; afe14dd fixes the forced `cloud-managed-visibility.test.ts` roster and adds the second changeset. Round 2's suites, ablation and derived gates ran on afe14dd (sections marked round 2). Round 3: 029cfa7 merges `origin/main` (571cf90, containing #34119's 41ff7c3) cleanly; a2f47bb adds the describe, comment, doc and nit fixes and the N4 pin. Round 3's suites and derived gates ran on a2f47bb; earlier sections are kept as they ran. <details><summary>Round 3 package suites (a2f47bb, after a full packages build)</summary> - `turbo run build --filter='./packages/**'` then `pnpm --filter @objectstack/spec check:generated --fix`: rewrote `content/docs/references/api/auth-endpoints.mdx` (the two `features.admin` rows), re-check green; after the final describe wording, spec rebuilt and `check:generated --fix` again, green. - `pending-sso-users.test.ts`: 58 passed (the N4 pin's first run red on `expected [ …2 rows ] to deeply equal []`: revocation stamps `sys_session` rows rather than deleting them, so the pin reads the stamp). - `pnpm --filter @objectstack/platform-objects test`: 122 files, 2003 passed. - `pnpm --filter @objectstack/plugin-auth test`: 277 files, 5566 passed, 10 skipped. - `pnpm --filter @objectstack/spec test`: 844 files, 26991 passed, 1 todo. </details> <details><summary>Round 3 derived gates (a2f47bb)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 116 commands (round 2's 88 plus 28 docs families, since `content/docs/**` is now in the change set); all 116 exited 0 on the first run. `--ran`: `116 derived famil(ies) accounted for — 116 run, 0 NOT-MEASURED`. CI-owned families are read from this PR's check-runs. No ablation this round: the N4 pin's own first red (above) and its `toEqual` on the declared defaults are what it stands on; the gate drops' ablations (rounds 1 and 2) are unchanged by round 3. </details> <details><summary>Round 2 measurement (25f44ac, Set Password gate in place)</summary> - `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts -t 34130`: 1 failed, 2 passed. The failure is `AssertionError: expected false to be true` at the unmanaged `set_user_password` offer; the managed case (hidden) and the plugin-on CONTROL passed. - Same run with the offer assertion removed in the working tree only (measure-only, restored with `git checkout HEAD`, `git diff HEAD` empty): 3 passed. </details> <details><summary>Round 2 ablation (each leg rebuilt platform-objects and read the built artifact)</summary> - Mutation: re-add `requiresFeature: 'admin'` to `set_user_password` (`ablation-replace.mjs`, anchor 1 to 0). Built `dist/identity/index.js` read: `requiresFeature: "admin",` above `recordIdParam: "userId"` / `successMessage: "Password updated"`. - `pending-sso-users.test.ts -t 34130`: 1 failed (the unmanaged offer, `expected false to be true`); managed and CONTROL green. - `action-state-visibility.test.ts`, `platform-objects.test.ts`, `feature-gate-guard.test.ts`, `cloud-managed-visibility.test.ts`: 5 failed. The Set Password offer case; the CONTROL roster (`expected [ 'create_user', …(2) ] to deeply equal [ 'create_user', 'impersonate_user' ]`); the lowering-matrix row; the guard's forward walk (`sys_user.actions.set_user_password is booked in admin.gatedInputs (or in SHOWN_WHEN_ON)`); the new "reads no other flag" case. - Restore: blob equals HEAD (afcbb2d), `git diff HEAD` empty; rebuilt; `ablation-dist-preflight.mjs … --absent`: marker absent from all 66 built files, tree clean. Re-run: 57 passed in `pending-sso-users.test.ts`, 325 passed in the four platform-objects files. </details> <details><summary>Round 2 package suites (afe14dd, after a full packages build)</summary> - `pnpm --filter @objectstack/platform-objects test`: 122 files, 2003 tests passed. Typecheck green. - `pnpm --filter @objectstack/plugin-auth test`: 277 files, 5530 passed, 10 skipped. Typecheck green. - `pnpm --filter @objectstack/spec test`: 843 files, 26966 passed, 1 todo. Typecheck green. - `pnpm --filter @objectstack/spec check:generated`: all 14 generated artifacts up to date. </details> <details><summary>Round 2 derived gates (afe14dd)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived the same 88 commands as round 1; all 88 exited 0 on the first run (the teardown self-test's fixture commit was already fetched). `--ran` reconciliation: `88 derived, 88 run, 0 NOT-MEASURED, 0 UNRUN`. CI-owned families are read from this PR's check-runs. </details> <details><summary>Round 1 measurement (8ec7d2c, gate in place)</summary> - `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts -t 34010`: 2 failed, 1 passed (CONTROL, plugin on). Both failures `AssertionError: expected false to be true` at the `unlock_user` offer (`features.admin` false hides it). - Same run with the offer assertion removed in the working tree only (measure-only, restored with `git checkout HEAD`, `git diff HEAD` empty): 3 passed. The door released the lock on both plugin-off kernels and refused the caller without the standing. </details> <details><summary>Round 1 ablation (each leg rebuilt platform-objects and read the built artifact)</summary> - Mutation: re-add `requiresFeature: 'admin'` to `unlock_user` (`ablation-replace.mjs`, anchor 1 to 0, blob f7a7aac to 2954695a). Built `dist/identity/index.js` read: `requiresFeature: "admin",` above `recordIdParam: "userId"` / `successMessage: "Account unlocked"`. - `pending-sso-users.test.ts -t 34010`: 2 failed (unmanaged and managed, `expected false to be true` at the offer); CONTROL green. - `action-state-visibility.test.ts`, `platform-objects.test.ts`, `feature-gate-guard.test.ts`: 4 failed. The Unlock offer case without the plugin; the CONTROL roster (`expected [ 'unlock_user', 'create_user', …(2) ] to deeply equal [ 'create_user', …(2) ]`); the lowering-matrix row; the guard's forward walk (`sys_user.actions.unlock_user is booked in admin.gatedInputs (or in SHOWN_WHEN_ON): expected false to be true`). - Restore: blob equals HEAD (f7a7aac), `git diff HEAD` empty; rebuilt; `ablation-dist-preflight.mjs @objectstack/platform-objects … --absent`: marker absent from all 66 built files, tree clean. Re-run: 3 passed in plugin-auth, 292 passed in the three platform-objects files. </details> <details><summary>Round 1 package suites (665d71a)</summary> - `pnpm --filter @objectstack/platform-objects test`: 122 files, 2005 tests passed. Typecheck green. - `pnpm --filter @objectstack/plugin-auth test`: 277 files, 5527 passed, 10 skipped. Typecheck green (after the full package build; its first attempt ran before plugin-auth's own `dist` existed and failed on `examples/basic-usage.ts` resolving `@objectstack/plugin-auth`, a build-state miss, not this diff). - `pnpm --filter @objectstack/spec test`: 843 files, 26966 passed, 1 todo. Typecheck green. - `pnpm --filter @objectstack/spec check:generated`: all 14 generated artifacts up to date. </details> <details><summary>Round 1 derived gates</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` on 665d71a derived 88 commands (the same 88 on f50eb24); each ran after a full `turbo run build --filter='./packages/**'`. 87 exited 0 on the first round. `check-plugin-teardown-shape.mjs --self-test` exited 3 (a prerequisite, not a verdict: its pinned fixture commit 621a487 was outside the shallow clone); after `git fetch origin 621a487…` it exited 0 (48 cases). `--ran` reconciliation: `88 derived, 88 run, 0 NOT-MEASURED, 0 UNRUN`. CI-owned families (`pnpm lint`, `test:repo`, dogfood) are read from this PR's check-runs. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmPhW5vcfV3ZnYyNhrB)_ <!-- signed: domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent c2cabce commit e0670b9

13 files changed

Lines changed: 325 additions & 86 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(platform-objects): Setup → Users offers Unlock Account on environments without the better-auth admin plugin
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
`sys_user.unlock_user` no longer carries `requiresFeature: 'admin'`. Its door, `POST /api/v1/auth/admin/unlock-user`, already works without the better-auth admin plugin: the sign-in lockout is ObjectStack's own (`sys_user.locked_until` / `failed_login_count`), and the unlock clears it through the data engine. The action was still hidden wherever `features.admin` is off, so a platform administrator there could not release a locked-out person early and had to wait for the lock to expire.
12+
13+
It is now offered on every environment that runs without the admin plugin, self-hosted and cloud-managed alike, to a platform administrator only, and only on an account that has a lock stamp or two-factor enabled. Nothing else changes: `requiredPermissions` and the predicate stay as they were, environments with the admin plugin (or SCIM, which turns it on) see no difference, and `create_user` and `impersonate_user` keep their admin-plugin gate (Set Password is released the same way, in its own note).
14+
15+
`PUBLIC_AUTH_FEATURES.admin.gatedInputs` in `@objectstack/spec/kernel` no longer lists `sys_user.actions.unlock_user`, since it is no longer gated on that flag.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(platform-objects): Setup → Users offers Set Password on self-hosted environments without the better-auth admin plugin
7+
8+
Clause-②: no (as #33989 and #34124 judge a gate drop)
9+
Metadata-protocol: none
10+
11+
`sys_user.set_user_password` no longer carries `requiresFeature: 'admin'`. Its door, `POST /api/v1/auth/admin/set-user-password`, is ObjectStack's own wrapper and already works without the better-auth admin plugin: it hashes and writes the password through better-auth's core, which every environment carries. The action was still hidden wherever `features.admin` is off, so a platform administrator there could not set or reset a person's password from the console.
12+
13+
It is now offered to a platform administrator on every environment that runs without the admin plugin and is not cloud-managed. Its other rule is unchanged: it stays hidden on a cloud-managed environment, whose door refuses every target, and the door's own refusals (a pending person, SSO-only mode) answer as before. `create_user` and `impersonate_user` keep their admin-plugin gate.
14+
15+
`PUBLIC_AUTH_FEATURES.admin.gatedInputs` in `@objectstack/spec/kernel` no longer lists `sys_user.actions.set_user_password`, since it is no longer gated on that flag.
16+
17+
The `features.admin` description in `@objectstack/spec` (`AuthFeaturesConfigSchema`, and the generated auth-endpoints reference page) no longer says the console shows Unlock Account and Set Password only when it is true: whether the console offers banning, unbanning, unlocking or setting a password does not depend on it.

‎content/docs/permissions/authentication.mdx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,9 +1165,10 @@ new AuthPlugin({
11651165

11661166
### Admin User Management
11671167

1168-
With `plugins: { admin: true }` (forced on when SCIM is enabled), platform
1169-
admins get email-independent account management on the Users list — the
1170-
`create_user` / `set_user_password` actions there drive these endpoints. All
1168+
Platform admins get email-independent account management on the Users list
1169+
— the `create_user` / `set_user_password` actions there drive these
1170+
endpoints. Creating a user needs `plugins: { admin: true }` (forced on when
1171+
SCIM is enabled); setting a password works with or without it. All
11711172
three routes are gated server-side on the session's `isPlatformAdmin` — the
11721173
`PLATFORM_ADMIN` standing of ADR-0095 D3 — with the legacy better-auth `role`
11731174
scalar of `admin` still accepted as a back-compat fallback; the
@@ -1552,7 +1553,7 @@ All endpoints are available under `/api/v1/auth/*`:
15521553
- `POST /api/v1/auth/phone-number/request-password-reset` - Request an OTP-based password reset (requires an SMS service)
15531554
- `POST /api/v1/auth/phone-number/reset-password` - Complete an OTP-based password reset
15541555

1555-
#### Admin User Management (requires `plugins.admin`; platform-admin gated)
1556+
#### Admin User Management (platform-admin gated)
15561557

15571558
- `POST /api/v1/auth/admin/create-user` - Create a login-capable account (optional one-time temporary password + forced change)
15581559
- `POST /api/v1/auth/admin/set-user-password` - Set/reset a user's password (also provisions a credential for SSO-onboarded users)
@@ -1563,7 +1564,7 @@ All endpoints are available under `/api/v1/auth/*`:
15631564
- `POST /api/v1/auth/admin/add-sso-user` - Add one pending person who signs in only through the hosting organisation's identity provider (cloud-managed environments only)
15641565
- `POST /api/v1/auth/admin/import-sso-users` - Add pending people from a CSV or JSON rows (cloud-managed environments only; ≤500 rows, per-row results)
15651566

1566-
`ban-user`, `unban-user`, `add-sso-user` and `import-sso-users` answer without `plugins.admin` too.
1567+
`create-user` and `import-users` need `plugins.admin` (without it they answer `501 NOT_IMPLEMENTED`). `set-user-password`, `unlock-user`, `ban-user`, `unban-user`, `add-sso-user` and `import-sso-users` answer with or without it.
15671568

15681569
#### Organization Membership (requires `plugins.organization`; platform-admin gated)
15691570

‎content/docs/references/api/auth-endpoints.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const result = AuthEndpointSchema.parse(data);
7676
| **degradedTenancy** | `boolean` | optional | Degraded tenancy: true when multi-organization isolation was requested but is not active (the deployment booted only because OS_ALLOW_DEGRADED_TENANCY=1), so no engine enforces organization boundaries; the console can raise an operator warning off it. A status signal, not a capability gate; absent means not degraded |
7777
| **oidcProvider** | `boolean` | optional | Embedded OIDC authorization server wired, from the same decision that mounts it, so OAuth applications can be registered and managed; on by default alongside the MCP surface. It says nothing about sign-in providers, which socialProviders lists; the flag is default-on, so absent reads as on |
7878
| **deviceAuthorization** | `boolean` | optional | Device authorization (browser-approved CLI login) wired, so the device-code endpoints answer; when false the console device-approval page says device authorization is not enabled instead of calling them. Absent means not wired |
79-
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it; the console still shows its unlock and set-password actions only when it is true. Absent means not wired |
79+
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
8080
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
8181
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |
8282

@@ -227,7 +227,7 @@ This schema accepts one of the following structures:
227227
| **degradedTenancy** | `boolean` | optional | Degraded tenancy: true when multi-organization isolation was requested but is not active (the deployment booted only because OS_ALLOW_DEGRADED_TENANCY=1), so no engine enforces organization boundaries; the console can raise an operator warning off it. A status signal, not a capability gate; absent means not degraded |
228228
| **oidcProvider** | `boolean` | optional | Embedded OIDC authorization server wired, from the same decision that mounts it, so OAuth applications can be registered and managed; on by default alongside the MCP surface. It says nothing about sign-in providers, which socialProviders lists; the flag is default-on, so absent reads as on |
229229
| **deviceAuthorization** | `boolean` | optional | Device authorization (browser-approved CLI login) wired, so the device-code endpoints answer; when false the console device-approval page says device authorization is not enabled instead of calling them. Absent means not wired |
230-
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it; the console still shows its unlock and set-password actions only when it is true. Absent means not wired |
230+
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
231231
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
232232
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |
233233

‎packages/platform-objects/src/identity/action-state-visibility.test.ts‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,19 @@ describe('sys_user Ban / Unban switch with `banned`', () => {
8484
});
8585

8686
/**
87-
* Ban / Unban are offered on a kernel WITHOUT the better-auth admin plugin:
88-
* their doors (plugin-auth `admin/ban-user` / `admin/unban-user`) are mounted
89-
* and enforce the ban there too, so `features.admin` off, the flag every such
90-
* kernel serves, managed or not, hides neither. The actions whose doors still
91-
* need the plugin keep their `requiresFeature: 'admin'` gate.
87+
* Ban / Unban / Unlock / Set Password are offered on a kernel WITHOUT the
88+
* better-auth admin plugin: their doors (plugin-auth `admin/ban-user` /
89+
* `admin/unban-user` / `admin/unlock-user` / `admin/set-user-password`) are
90+
* mounted and work there too, so `features.admin` off, the flag every such
91+
* kernel serves, managed or not, hides none of them (Set Password keeps its
92+
* own hide-when-cloud-managed rule). The actions whose doors still need the
93+
* plugin keep their `requiresFeature: 'admin'` gate.
9294
*/
93-
describe('sys_user Ban / Unban are offered without the admin plugin', () => {
95+
describe('sys_user Ban / Unban / Unlock / Set Password are offered without the admin plugin', () => {
9496
const ban = visibleOf(SysUser, 'ban_user');
9597
const unban = visibleOf(SysUser, 'unban_user');
98+
const unlock = visibleOf(SysUser, 'unlock_user');
99+
const setPassword = visibleOf(SysUser, 'set_user_password');
96100
/** What a kernel without the plugin serves: unmanaged (self-hosted) and managed (a Free or Team environment). */
97101
const WITHOUT_PLUGIN = [
98102
{ admin: false, apiKey: true, cloudManaged: false },
@@ -109,21 +113,36 @@ describe('sys_user Ban / Unban are offered without the admin plugin', () => {
109113
}
110114
});
111115

116+
it('a locked or two-factor account is offered Unlock and one with neither is not, managed or not', () => {
117+
for (const features of WITHOUT_PLUGIN) {
118+
const where = JSON.stringify(features);
119+
expect(offered(unlock, { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: false }, ADMIN, features), where).toBe(true);
120+
expect(offered(unlock, { locked_until: null, two_factor_enabled: true }, ADMIN, features), where).toBe(true);
121+
expect(offered(unlock, { locked_until: null, two_factor_enabled: false }, ADMIN, features), where).toBe(false);
122+
}
123+
});
124+
125+
it('Set Password is offered unmanaged and stays hidden managed, its own rule kept', () => {
126+
const [unmanaged, managed] = WITHOUT_PLUGIN;
127+
expect(offered(setPassword, { source: 'env_native' }, ADMIN, unmanaged!)).toBe(true);
128+
expect(offered(setPassword, { source: 'env_native' }, ADMIN, managed!)).toBe(false);
129+
});
130+
112131
it('the standing leg stays: a caller without it is offered neither with the plugin off', () => {
113132
for (const features of WITHOUT_PLUGIN) {
114133
for (const banned of [true, false]) {
115134
expect(offered(ban, { banned }, MEMBER, features)).toBe(false);
116135
expect(offered(unban, { banned }, MEMBER, features)).toBe(false);
117136
}
137+
expect(offered(unlock, { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: true }, MEMBER, features)).toBe(false);
138+
expect(offered(setPassword, { source: 'env_native' }, MEMBER, features)).toBe(false);
118139
}
119140
});
120141

121142
// CONTROL: the admin-plugin-only actions. Each row is one its predicate
122143
// otherwise offers, so the flag alone decides.
123144
const PLUGIN_ONLY: ReadonlyArray<[string, Record<string, unknown>]> = [
124-
['unlock_user', { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: true }],
125145
['create_user', {}],
126-
['set_user_password', { source: 'env_native' }],
127146
['impersonate_user', {}],
128147
];
129148

‎packages/platform-objects/src/identity/cloud-managed-visibility.test.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* flag the payload lacks (`default-on` ones too), so that case is the
1616
* consumer's fault handling, the same for every flag.
1717
*
18-
* Each of the six already carries another flag's gate (`organization` or
19-
* `admin`) through `requiresFeature`, so the `cloudManaged` gate is written in
20-
* `visible` and the two compose. The predicates are EVALUATED through the
18+
* Five of the six also carry another flag's gate (`organization` or `admin`)
19+
* through `requiresFeature`, so the `cloudManaged` gate is written in
20+
* `visible` and the two compose. `set_user_password` carries none: its door
21+
* works without the better-auth admin plugin (the admin block header in
22+
* `sys-user.object.ts`), so `cloudManaged` is its only flag. The predicates are EVALUATED through the
2123
* canonical engine the console delegates to (`@objectstack/formula`), on the
2224
* parsed object, so the lowered envelope is what is judged; a string match
2325
* would stay green on a predicate that faults or never answers true.
@@ -33,7 +35,7 @@ import { SysOrganization } from './sys-organization.object.js';
3335
/** Holds every standing the six doors ask for: the platform-admin rung and the owner grade. */
3436
const ADMIN = { id: 'u_admin', email: 'admin@example.com', positions: ['org_owner'], isPlatformAdmin: true };
3537

36-
/** The other flags the six inputs are gated on, all on, so `cloudManaged` alone decides. */
38+
/** The other flags five of the six inputs are gated on, all on, so `cloudManaged` alone decides. */
3739
const OTHER_FLAGS = { organization: true, admin: true };
3840

3941
const SIX: ReadonlyArray<[string, { actions?: unknown }, string]> = [
@@ -73,9 +75,18 @@ describe('features.cloudManaged hides the six doors that add people', () => {
7375
expect(offered(visibleOf(def, name), { ...OTHER_FLAGS, cloudManaged: false })).toBe(true);
7476
});
7577

76-
it.each(SIX)('%s keeps its other flag: off hides it whatever cloudManaged says', (_site, def, name) => {
78+
/** The five that carry another flag; `set_user_password` carries only `cloudManaged`. */
79+
const GATED_TWICE = SIX.filter(([site]) => site !== 'sys_user.set_user_password');
80+
81+
it.each(GATED_TWICE)('%s keeps its other flag: off hides it whatever cloudManaged says', (_site, def, name) => {
7782
expect(offered(visibleOf(def, name), { organization: false, admin: false, cloudManaged: false })).toBe(false);
7883
});
84+
85+
it('sys_user.set_user_password reads no other flag: offered with the admin plugin off, hidden managed', () => {
86+
const source = visibleOf(SysUser, 'set_user_password');
87+
expect(offered(source, { organization: false, admin: false, cloudManaged: false })).toBe(true);
88+
expect(offered(source, { organization: false, admin: false, cloudManaged: true })).toBe(false);
89+
});
7990
});
8091

8192
/**

‎packages/platform-objects/src/identity/sys-user-set-manager-action.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ describe('the visible predicate: offered on every row, the SCIM-held refusal is
198198
});
199199

200200
it('⛔ is NOT gated on features.admin, and that is deliberate', () => {
201-
// The `admin` flag hides buttons whose endpoint is "only wired when
202-
// `auth.plugins.admin` is enabled" — the 404-avoidance the block header on
203-
// the admin actions states. This route is not one of those: it is an
201+
// The `admin` flag hides buttons whose endpoint needs the better-auth
202+
// admin plugin, so that the UI does not render buttons that 404 (the block
203+
// header on the admin actions). This route is not one of those: it is an
204204
// ObjectStack mount registered unconditionally beside `unlock-user` and
205205
// authorized by the ADR-0068 platform-admin gate, so gating it would hide
206206
// a WORKING affordance on every host that never opted into that plugin —

0 commit comments

Comments
 (0)