Skip to content

feat(identity): sys_user 放开档案字段标准编辑 affordance(ADR-0092 D4,closes #2817)#2832

Merged
os-zhuang merged 3 commits into
mainfrom
claude/sys-user-field-delegation-4p8l20
Jul 11, 2026
Merged

feat(identity): sys_user 放开档案字段标准编辑 affordance(ADR-0092 D4,closes #2817)#2832
os-zhuang merged 3 commits into
mainfrom
claude/sys-user-field-delegation-4p8l20

Conversation

@os-zhuang

@os-zhuang os-zhuang commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

概要

ADR-0092 D4(#2817)—— sys_user 档案字段经标准编辑表单可编辑,运行中的 Console 端到端验证通过(编辑 name → 落库;email/role 只读)。守卫 #2828 仍确保用户上下文只能改 {name, image}

三块协同改动:

  1. sys_user schemaplatform-objects)— userActions:{edit:true};name/image 可编辑,其余标 readonly
  2. /me/permissions 提示 = 权限 ∩ 守卫plugin-hono-server,新增 foldWildcardSuperUser + clampManagedObjectWrites + 8 单测)。
  3. .objectui-sha → 5da9905 — 拉入 objectui feat(auth): per-org MFA + dispatcher/MCP gate (ADR-0069 D3) #2395ObjectFormuserActions.edit 逐字段渲染)。

根因与完整修复(浏览器验证中发现,逐层查明)

放开 affordance 后表单仍全禁用,原因是两个独立门:

服务端对身份表有两层强制:权限集(checkObjectPermission,最宽松合成、无 deny-wins,admin 的 modifyAllRecords 通配符放行) 身份写守卫 #2828(全 managedBy:'better-auth' 表默认拒用户上下文写,仅 sys_useredit)。/me/permissions 原来两层都没反映,于是:

  1. foldWildcardSuperUser 折入通配符超级用户位 → 修假阴性(admin 看不到 sys_user 可编辑,但 PATCH /data/sys_user{name}→200 证明服务端放行)。
  2. clampManagedObjectWrites 按守卫策略夹回 → 修 fold 引入的假阳性:sys_member/sys_account/sys_session 等无白名单托管表夹回 allowEdit:false(read 保留),与守卫一致。仅夹 better-auth 对象(守卫只管它们);system/config/append-only 无此守卫,权限集结果照旧(admin 可经 data API 写,提示不得漏报)。

结果:客户端 per-object FLS = 真实服务端强制(权限 ∩ 守卫),双向不一致均消除。此前担心的"admin 在所有 system 表看到编辑按钮"的影响面已由 clamp 消除。

验证

相关

ADR-0092 D4/D5 · closes #2817 · 修复 #2836(权限合成 finding)· 依赖已合并 #2828、objectui #2395 · 关联 #2833

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21

… fields (ADR-0092 D4)

sys_user gains userActions:{edit:true} (create/import/delete stay off).
name/image are editable; email, email_verified, two_factor_enabled, role,
banned/ban_reason/ban_expires, ai_access, manager_id,
primary_business_unit_id and every system-managed stamp are marked
readonly so the standard edit form renders them non-editable.

Safe because the server boundary is the identity write guard (ADR-0092
D2, #2828): a user-context sys_user update may only touch {name, image}
regardless of what a form submits. The readonly flags are UX only.

Verified in the running Console: the object metadata sent to the client
carries userActions.edit=true and the correct per-field readonly flags;
the row 'Edit' action appears; the edit form surfaces only name/image;
and — the risk this issue flagged — the create_user/invite_user dialogs
keep email/role editable (action params do not inherit field readonly).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 11, 2026 10:57am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling size/s labels Jul 11, 2026
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/plugin-hono-server.

5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/permissions/authentication.mdx (via @objectstack/plugin-hono-server)
  • content/docs/plugins/index.mdx (via @objectstack/plugin-hono-server)
  • content/docs/plugins/packages.mdx (via @objectstack/platform-objects, @objectstack/plugin-hono-server)
  • content/docs/releases/implementation-status.mdx (via @objectstack/plugin-hono-server)
  • content/docs/ui/setup-app.mdx (via @objectstack/platform-objects)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

…ect FLS + bump objectui to sys_user edit-form fix (ADR-0092 D4)

Completes ADR-0092 D4 end-to-end (#2817). Three parts brought the standard
sys_user edit form to life for platform admins, verified in a running
Console (edit name → persisted; email/role stay read-only):

1. foldWildcardSuperUser in /me/permissions (hono-plugin): the per-object
   FLS map now folds the '*' modifyAll/viewAll super-user grant into every
   object entry, so the client mirrors the server's actual enforcement
   (checkObjectPermission is most-permissive, no deny-wins). Fixes the
   false-negative where a platform admin who also holds organization_admin
   (denies identity writes) saw sys_user.allowEdit:false and a disabled
   form, though the server accepts the write (PATCH → 200). ADR-0057 D10.
2. .objectui-sha bump to 5da9905 — pulls in objectui#2395 (ObjectForm
   honors userActions.edit instead of blanket-disabling managed objects).
3. sys_user userActions.edit + field readonly governance (earlier commit).

The identity write guard (#2828) still restricts the actual write to
{name, image}; these changes only correct which affordances the UI shows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21
…ission ∩ guard (ADR-0092 complete fix)

Completes the /me/permissions consistency fix. foldWildcardSuperUser
alone fixed the false-NEGATIVE (admin couldn't see sys_user editable)
but introduced a false-POSITIVE: it reported allowEdit:true for every
better-auth identity table, including ones the identity write guard
(#2828) actually blocks (sys_member, sys_account, sys_session, …).

clampManagedObjectWrites re-applies the guard's user-context policy: a
managedBy:'better-auth' object is writable only where it opted in via
userActions.{edit,create,delete} (sys_user → edit; the field readonly
flags then narrow it to {name,image}). Only better-auth objects are
clamped — system/config/append-only have no such guard, so their
permission-set result stands (admin CAN write them; must not under-report).

Net: the Console's per-object FLS now equals real server enforcement
(permission-set ∩ guard). Verified against a running stack: sys_user
allowEdit:true + form editable; sys_member/session/account allowEdit:false
(read preserved). +4 unit tests (8 total).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21
@os-zhuang
os-zhuang marked this pull request as ready for review July 11, 2026 12:20
@os-zhuang
os-zhuang merged commit 6da03ee into main Jul 11, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/sys-user-field-delegation-4p8l20 branch July 11, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(identity): ADR-0092 实现 B — sys_user 放开 edit affordance + 表单字段只读治理(依赖 #2816)

2 participants