Repository navigation
fix(platform-objects): offer Ban / Unban without the better-auth admin plugin - #33989
Conversation
…n plugin Claude-Session: https://claude.ai/code/session_01ADHkmRTCRCDzKb12eoW83s Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRTCRCDzKb12eoW83s Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRTCRCDzKb12eoW83s Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRTCRCDzKb12eoW83s Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 173 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 db0ab0efd8e40fab3c74c015bf3b1446ee99af33 && git checkout db0ab0efd8e40fab3c74c015bf3b1446ee99af33
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bc6b7ffd454ba9c2c420975c84a400779cb02262 9d6dba495fe8727febe113a7252bac82e99ed10f && git checkout -B drift-repro bc6b7ffd454ba9c2c420975c84a400779cb02262 && git merge --no-ff 9d6dba495fe8727febe113a7252bac82e99ed10f
node scripts/docs-audit/affected-docs.mjs --json bc6b7ffd454ba9c2c420975c84a400779cb02262
|
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Contract reviewServed-tier: Inputs read: card #33759 with its Claim (6896010564) and os-dev-report (6896885009); this PR's body, file list and net diff against ① Derived judgments
② Semver levelClause-②: no — upheld; see ③ for the open question on the spec half. The changeset names ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
The live pin is the right shape for the claim: it reads the DECLARED action's Nits (no effect on correctness or the contract):
Implemented-by: VERDICT: PASS Reviewed 2026-11-15T16:01Z. |
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 席位核对Verdict: ACCEPT · head
|
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Contract reviewServed-tier: Inputs read: card #33759 with its Claim (6896010564) and os-dev-report (6896885009); this PR's body, file list, comments and net diff against Check-runs on this head when this record was written: 67 runs, all concluded: 56 ① Derived judgments
② Semver levelClause-②: no — upheld. Offering two existing actions on more kernels widens no accepted input and removes no declared capability; the spec half is answered under ③. The changeset names ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
The rule "
The block header's new paragraph was read sentence by sentence against the same code and holds. The remaining findings are nits; none changes correctness or the contract.
Implemented-by: VERDICT: PASS Reviewed 2026-11-15T16:42Z. |
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 落地Landing approved by the maintainer in the seat thread at 2026-11-15T16:10Z ("批准席位 本班复核通过的 PR 执行 --land"). The ACCEPT head
State change: on MERGED, |
…e admin plugin (objectstack-ai#34119) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9XmUTbwghz9gpc54Frpqhjn)_ Fixes objectstack-ai#34008 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:三处 spec 描述(`authFamilies.admin`、`features.admin`、`plugins.admin`)和 actions 文档示例不再说「停用/恢复、解锁、重设密码需要 admin 插件」,按实测列出真正依赖插件的操作;引用文档随之重新生成。 - 为什么改:停用/恢复、解锁、重设密码这四个接口是平台自带的,不装 admin 插件也能用;旧说法会让 AI 和开发者给这些按钮错误地加上 admin 门控。 - 风险与回滚:只改文字,没有任何 schema 接受或拒绝的结果变化;回滚即还原本 PR。 - 先看:`packages/spec/src/api/discovery.zod.ts`、`content/docs/protocol/objectui/actions.mdx`、`packages/spec/src/api/auth-endpoints.zod.ts`。 - 两分钟验证:`git grep -n "update-user, ban-user" -- packages/spec/src content/docs` 应无结果。 - 需要你做的:无,席位落地。 ## What changes - `AuthFamiliesSchema.admin` describe (`packages/spec/src/api/discovery.zod.ts`): the example family member `ban-user` is replaced by `impersonate-user`, and one sentence says `ban-user` and `unban-user` are not in the family: they are ObjectStack mounts, served whatever the flag says. Still one paragraph. - `features.admin` describe (`packages/spec/src/api/auth-endpoints.zod.ts`): creating and impersonating users are the operations that need the plugin; banning, unbanning, unlocking and setting a password answer without it, and the describe says the console still shows its unlock and set-password actions only when the flag is true. - `plugins.admin` describe and JSDoc (`packages/spec/src/system/auth-config.zod.ts`): the JSDoc lists the endpoints that need the plugin (`create-user`, which answers `501` without it, `impersonate-user` / `stop-impersonating`, `set-role`, `remove-user`, `GET list-users`, `list-user-sessions`, `revoke-user-session(s)`) apart from the four ObjectStack mounts served without it (`ban-user`, `unban-user`, `unlock-user`, `set-user-password`), described as mounts rather than the plugin's routes, with no claim about how they write. "better-auth enforces this internally" is replaced: the ObjectStack mounts, `create-user`, `remove-user` and the rebuilt `impersonate-user` run the ADR-0068 gate, the vendor routes keep better-auth's legacy `user.role` check, and `stop-impersonating` is neither: better-auth admits it on the impersonated session with the signed `admin_session` cookie `impersonate-user` set (read from `better-auth/dist/plugins/admin/routes.mjs` 1.7.12, which also declares `list-users` as `GET`). "assign global platform roles" is gone. The describe follows the same split. - `content/docs/protocol/objectui/actions.mdx`: the `requiresFeature: admin` worked example gates `impersonate_user` (`/api/v1/auth/admin/impersonate-user`) in place of `ban_user`. The second example (`disable_oauth_application`) is unchanged. - Regenerated: `content/docs/references/api/{discovery,protocol,auth-endpoints}.mdx`, `content/docs/references/system/auth-config.mdx` (`check:generated --fix`, which named only `check:docs` stale). - `.changeset/34008-ban-without-admin-plugin-prose.md`: `patch` on `@objectstack/spec`. ## Why The measurement, on `origin/main` at `27c2f1ea`. A throwaway probe (the `pending-sso-users.test.ts` harness, one platform admin, deleted after the run, not committed) fired each door with `plugins.admin` off and on: | door | off | on | |---|---|---| | `features.admin` | false | true | | `/admin/unlock-user` | 200 | 200 | | `/admin/set-user-password` | 200 | 200 | | `/admin/ban-user` | 200 | 200 | | `/admin/unban-user` | 200 | 200 | | `/admin/set-role` | 404 | 200 | | `/admin/create-user` | 501 `NOT_IMPLEMENTED` | 200 | | `/admin/impersonate-user` | 404 | 200 | Source reading: - `packages/plugins/plugin-auth/src/auth-plugin.ts`: `POST {basePath}/admin/ban-user` and `/admin/unban-user` are raw Hono mounts with no admin-plugin condition. Without the plugin, `getBanWriter` writes through the data engine (`isAdminPluginMounted()` false) and the session refusal enforces the ban. `pending-sso-users.test.ts` pins this ("a row banned while the admin plugin was on stays refused after the plugin is turned off", the ban / unban cases with the plugin off, and a CONTROL with it on). - `sys_user.ban_user` / `unban_user` carry no `requiresFeature`, and `PUBLIC_AUTH_FEATURES.admin.gatedInputs` (`packages/spec/src/kernel/public-auth-features.ts`) books neither, with a note saying why. - Routes that still answer 404 when `features.admin` is false: the better-auth vendor routes with no ObjectStack mount: `list-users`, `set-role`, `update-user`, `list-user-sessions`, `revoke-user-session(s)`, `stop-impersonating`, and `impersonate-user` (replaced on the admin plugin's own `endpoints` record by `admin-impersonate-endpoint.ts`, so it exists only with the plugin). The dogfood pin `discovery-auth-families.dogfood.test.ts` reads `GET /auth/admin/list-users` as 404 with the plugin off and not 404 with it on. `sys_user.impersonate_user` declares `requiresFeature: 'admin'`, which is why it is the docs example now. - ObjectStack mounts such as `create-user` stay mounted without the plugin but answer `501 NOT_IMPLEMENTED`; the describe's family list does not name them, so this PR does not touch that wording. ## Tests - `pnpm --filter @objectstack/spec test` at `6fe7a568`: Test Files 843 passed (843), Tests 26966 passed | 1 todo. Lock VERDICT command-exit 0. - No test edit was forced. No test pins the old wording (`git grep` of the three old phrases outside `packages/spec/src`, references and CHANGELOGs finds only the two out-of-scope copies listed below). - No ablation: prose only. ## Acceptance notes - Out of the card's paths, two copies of a related phrase, not changed here: - `packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts:312`, a code comment "Platform admin: ban/unban, set-password, impersonate, set-role." beside the admin plugin's registration. With the plugin on, the vendor's ban hook still enforces, so it is loose rather than false. `domain:server`. - `docs/qa/platform-checklist/areas/identity-auth.json` item `identity-auth.admin-lifecycle-operations` title lists ban/unban among "admin user-lifecycle operations"; it makes no plugin claim. `domain:devx`. - `content/docs/releases/v18/18-5.mdx` and `packages/spec/CHANGELOG.md` keep their historical wording (release-owned). - `content/docs/permissions/authentication.mdx` already says ban / unban answer without `plugins.admin`; unchanged. - No `skills/**` file teaches the old rule (`git grep -n "ban-user\|ban_user\|unban" -- skills` is empty), so no skills follow-up. - The console's `sys_user.unlock_user` and `sys_user.set_user_password` declare `requiresFeature: 'admin'` (`packages/platform-objects/src/identity/sys-user.object.ts`) and `PUBLIC_AUTH_FEATURES.admin.gatedInputs` books both, while their doors answer 200 with the plugin off (probe above). On a deployment without the admin plugin the two buttons are hidden though the doors work: the same shape the ban / unban buttons had before PR objectstack-ai#33989. Not changed here (platform-objects + kernel feature table); for the seat to file. The `features.admin` describe states the current console behaviour as it is. - File surface: the claim names `discovery.zod.ts` and `content/docs/**`; the delta also asks for other `packages/spec/**` copies, which added `auth-endpoints.zod.ts` and `auth-config.zod.ts`. ## Verification <details><summary>Derived gates at 6fe7a56: 104 derived, 103 run green, 1 NOT MEASURED</summary> - `node scripts/pm/dispatch-gates.mjs --ran` on the final record: "104 derived famil(ies) accounted for — 103 run, 1 NOT-MEASURED". - NOT MEASURED: `pnpm check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET (reads every package's `dist/`; this container built only the spec, lint and client-react closures). CI runs it. - Every derived gate ran once at `6fe7a568`, with `NODE_OPTIONS=--max-old-space-size=4096` exported for the whole run, and all 103 exited 0 on that first run. Earlier heads needed reruns: at `97b9f14c`, `spec check:generated` ran its `check:test-typecheck` `tsc` out of heap without that flag; at `36887238`, `check-plugin-teardown-shape.mjs --self-test` needed its pinned fixture commit fetched into the shallow clone. - Record: project share `spec-seat2/34008-gates-ran-r3.txt`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmNsjxB7oSL12vpVvW6 <!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Fixes #33759
Clause-②: no — offering an existing action in more kernels widens no accepted input set or public export; the dev measures the gaining kernels and the seat amends if the diff reads otherwise
Metadata-protocol: none
维护者速读
ban_user/unban_user)去掉了requiresFeature: 'admin',没开 better-auth admin 插件的环境(自托管默认、托管的 Free/Team 环境)现在也会显示这两个按钮;规格里 admin 特性的门禁登记表同步去掉这两项。403 BANNED_USER拒绝),但按钮仍要求 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(新的实跑钉子)。pnpm --filter @objectstack/plugin-auth exec vitest run src/pending-sso-users.test.ts -t 33759,预期 3 个用例全绿(未托管、托管两种内核各一次封禁/解封实跑,加一个对照)。What changes
sys_user.ban_userandsys_user.unban_userdroprequiresFeature: 'admin'. Theirvisiblepredicates (the platform-admin standing, then the row'sbannedstate) andrequiredPermissionsare unchanged. The admin block header insys-user.object.tsnow says which actions keep the admin-plugin gate and why these two do not.PUBLIC_AUTH_FEATURES.admin.gatedInputs(packages/spec/src/kernel/public-auth-features.ts) no longer books the two actions. This is forced, not chosen:feature-gate-guard.test.tsholds the registry and the lowered predicates in lockstep in both directions, so a booked input without the gate reds its forward walk.@objectstack/platform-objectspatch and@objectstack/specpatch (the registry edit ships in spec).Why
Since #33227 (
cbb876c1)POST /api/v1/auth/admin/ban-userandunban-userwork on a kernel without the better-auth admin plugin: the ban is written through the data engine and the banned row is refused a session with403 BANNED_USER. The two actions were still hidden whereverfeatures.adminis off, so a platform admin there had no Deactivate / Reactivate in the console.Clause-② reading (measured)
features.adminis served aspluginConfig.admin ?? resolveScimEnabled(pluginConfig)(plugin-auth/src/auth-manager.ts, theadmin:row of the public features). So every kernel where the admin plugin is not configured on and SCIM is not effective gains them: self-hosted kernels on the default config, and cloud-managed Free / Team environments, where the plugin mounts only with SCIM. Measured in the live pin below: the harness kernel withplugins.admin: falseservesfeatures.admin === falseboth withOS_CLOUD_MANAGEDunset and set, and the declared actions are offered on both; withplugins.admin: trueit servestrue. Kernels with the plugin (or SCIM) on already offered both and see no change.auth-plugin.ts, theadmin/ban-user/admin/unban-usermounts). Nothing server-side readsvisible:packages/runtime/src/action-dispatch.tsandpackages/runtime/src/domains/mcp.tscarry zerovisible/featuresreads (tree a1fd372), so the AI / MCP exposure of the twoai.exposedactions is the same as before. Only the console's offer changes.PUBLIC_AUTH_FEATURESkeeps its name and declared entry shape; itsadmin.gatedInputsvalue loses two strings, and since the object isas const, its literal tuple type loses two members. Readers ofgatedInputsin this repository (packages, ui, scripts, apps; tree a1fd372):spec/src/kernel/public-auth-features.test.tsandplatform-objects/src/feature-gate-guard.test.tsonly, plus a comment insys-user-set-manager-action.test.ts.check:api-surfaceandcheck:generatedare green. Read as not a narrowing of a public export; the seat amends the line if it reads otherwise.Tests
identity/action-state-visibility.test.ts, new describesys_user Ban / Unban are offered without the admin plugin: evaluated through@objectstack/formula'scelEngineon the parsed object, withfeatures.adminoff on an unmanaged and a managed feature set: Ban is offered on a not-banned row and Unban on a banned one; the standing leg still hides both from a non-admin; CONTROL, exactlyunlock_user,create_user,set_user_password,impersonate_userstill readfeatures.admin, and each stays hidden with it off and is offered with it on.plugin-auth/src/pending-sso-users.test.ts, new top-level describe[#33759] Ban / Unban are offered and work without the admin pluginin the existing shared harness (a realAuthManagerbehindAuthPlugin.registerAuthRouteson a Hono app,plugins.admin: false): for an unmanaged and a managed kernel, the DECLAREDban_useris offered under the features this kernel serves (getPublicConfig().features), itstargetwith itsrecordIdParamandbanReasonanswers 200, the banned row's next sign-in is403with codeBANNED_USERand no session row, thenunban_useris offered, answers 200, and sign-in is 200 again. CONTROL:impersonate_useris hidden on that kernel and offered on one with the plugin on.platform-objects/src/platform-objects.test.ts(thefeature-gate lowering matrix (#2874)rows forban_user/unban_usernow pin the bare predicate, since nothing is lowered onto it).feature-gate-guard.test.tsneeded no edit; its forward rows are derived from the registry.Acceptance notes
visibleline) was contained in its own replacement, soablation-replace.mjsrefused it (anchor 1 to 1) and restored the file; no run was read from it. The legs below re-anchor on thevisible/recordIdParampair.unlock_userkeepsrequiresFeature: 'admin', though theset_user_managercomment callsadmin/unlock-usera mount registered unconditionally. Whether that door works without the plugin was not measured here.Verification
Code and tests are final at a1fd372; 8631da3 adds only the changeset's
@objectstack/specline. Suites and ablations ran on a1fd372, the derived gates on 8631da3.Ablations (each leg rebuilt platform-objects and read the built artifact)
requiresFeature: 'admin'toban_user(ablation-replace, anchor 1 to 0). Builtdistread:ban_user.visible = (current_user.isPlatformAdmin == true && has(record.banned) && record.banned != true) && features.admin == true.action-state-visibility.test.ts: 2 failed (the offer case and the CONTROL roster).pending-sso-users.test.ts -t 33759: 2 failed (unmanaged and managed,expected false to be trueat the Ban offer), CONTROL green. Restore: blob equals HEAD,git diff HEADempty, rebuilt,distread shows the bare predicate, both files green (18/18, 3 passed).unban_user. 2 failed in each file, same cases; restored green.Package suites
pnpm --filter @objectstack/platform-objects test: 122 files, 1995 tests passed. Typecheck green.pnpm --filter @objectstack/plugin-auth test: 277 files, 5488 passed, 10 skipped. Typecheck green.pnpm --filter @objectstack/spec test: 842 files, 26956 passed, 1 todo. Typecheck green.pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon 8631da3 derived 88 commands; each was run after a fullturbo run build --filter='./packages/**'(81/81 tasks) and all 88 exited 0.--ranreconciliation:88 derived, 88 run, 0 NOT-MEASURED, 0 UNRUN(a derived zero). Two first-round exit-3 prerequisites were cleared before that round:check-plugin-teardown-shape --self-testneeded its pinned fixture commit fetched into the shallow clone, andcheck:dual-build-cjs-loads/check:i18nneeded the full package build. CI-owned families (pnpm lint,test:repo, dogfood) are read from the PR's check-runs.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI-owned).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed (none stale).content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code