Repository navigation
feat(plugin-auth): serve the platform-admin roster from Setup → Users (#28793) - #29427
Conversation
Export the last-admin guard's enumerator (resolveAdminUserIds) with a platform-admins scope, serve its candidates confirmed by hasPlatformAdminStanding at POST /api/v1/auth/admin/list-platform-admins to a caller who holds that standing, add the sys_user list toolbar entry, and pin the enumerator's candidate sources in the admin-standing ledger. Claude-Session: https://claude.ai/code/session_01ADHkmQKiS3hSX11hKXCKNN Co-authored-by: Claude <noreply@anthropic.com>
… add changeset Claude-Session: https://claude.ai/code/session_01ADHkmQKiS3hSX11hKXCKNN Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 50 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 873211988e90663a336c3f9f1e6df655943d439b && git checkout 873211988e90663a336c3f9f1e6df655943d439b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0e0ddacda7dd4004283bd45610dfb5443dcf9ecd 365488e517ed42a5afda08be6107ec5a5631da5d && git checkout -B drift-repro 0e0ddacda7dd4004283bd45610dfb5443dcf9ecd && git merge --no-ff 365488e517ed42a5afda08be6107ec5a5631da5d
node scripts/docs-audit/affected-docs.mjs --json 0e0ddacda7dd4004283bd45610dfb5443dcf9ecd
|
…ep, pin its live answer (#28793) admin-platform-admin-standing's /admin/ sweep failed by name on the new mount (unclassified). It joins ADMITTED with its empty payload, and a C-28793 case pins the booted stack's answer: the platform admin is on the roster and the plain member is not. The changeset declares Clause-②: yes (widening): a new public route and new exports. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQKiS3hSX11hKXCKNN
|
domain:server#5 · os-steve · session_01ADHkmQKwKFCp1m6Pb6Q8c1 维护者速读
席位意见:与 diff 相符。第 2 轮把声明改正为 席位核对ACCEPT ·
|
Requested by Steve · project thread
Fixes #28793
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
role列移除后,列表上看不出谁是平台管理员;按裁决 C,用 last-admin guard 里现成的枚举器给出名单,每个人再用同一个判定hasPlatformAdminStanding逐个确认。packages/plugins/plugin-auth/src/last-admin-guard.ts(枚举器抽出与导出,风险点在createStandingReader与standing参数),packages/plugins/plugin-auth/src/platform-admin-roster.ts(调用者资格二次确认),packages/core/src/security/admin-standing-surface.ts(台账钉)。pnpm --filter @objectstack/plugin-auth exec vitest run src/platform-admin-roster.pin.test.ts,预期 12 个用例全绿(名单与判定逐人一致、组织管理员被拒)。What changes
last-admin-guard.ts's standing reads (scan, the ledger and Default Organization reads,anchorOwnerTest,resolveAdminUserIds) move, text unchanged, from insideregisterLastAdminGuardinto a module-levelcreateStandingReader(engine, maxScan). The guard destructures them from it, so its behaviour is unchanged. The new exportresolveAdminUserIds(engine, { standing, maxScan })reads through the same reader:standing: 'administrators'(default) is the guard's population, and'platform-admins'skips the organization owner and admin half. An overflowing read on the roster path throws the guard's existing 503SERVICE_UNAVAILABLEread fault instead of a refusal worded for a write.POST /api/v1/auth/admin/list-platform-admins(auth-plugin.ts, same family asset-user-manager):gateAdminfirst, thenrunPlatformAdminRoster(platform-admin-roster.ts). The handler confirms the caller throughhasPlatformAdminStandingas well, because the shared gate still honours the legacyrolescalar as a fallback and the roster names platform operators. A non-holder gets the gate's own 403PERMISSION_DENIEDbody (PLATFORM_ADMIN_REFUSAL_MESSAGES[403]). It enumerates the candidates and keeps those the predicate confirms, then answers{ count, admins: [{ id, name, email }], entries }. No body is read: platform standing belongs to no organization, and the console addsorganizationIdto every auth action. Ledgered inauth-route-ledger.ts.sys_user.list_platform_admins: onelist_toolbaraction posting to the route,visible: 'current_user.isPlatformAdmin == true'like the other platform-admin actions,refreshAfter: false, and aresultDialogdrawingentriesas acode-list. There is noaiblock, because the action postdates the ADR-0011 identity-actions assessment and an unassessed action stays human-only. Translated in the four packs (zh-CN, ja-JP and es-ES written by hand, regenerated withcheck-i18n-bundles --write).ADMIN_STANDING_PLATFORM_ENUMERATION(admin-standing-surface.ts) names the enumerator and sorts every input of the administrator derivation intocandidateSources(sys_user_permission_set,OS_PLATFORM_OWNER_EMAIL) ornotCandidates. The core test holds that classification to exactly the declared deriving tables and non-table inputs. plugin-auth'splatform-admin-roster.pin.test.tsrequires a sole-source fixture per candidate that the enumerator finds. A third source is red at one of the two until the enumerator reads it.set_user_manager/POST /admin/set-user-manager: atype: 'api'sys_user action to an ObjectStack/admin/*mount behindgateAdmin. It is POST becauseActionSchema.methodhas no GET member.Forced test edits, each a list a new mount must join:
auth-route-ledger.conformance.test.ts: the hand-written objectstack-mount list gains the route.packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts: the/admin/sweep's expectation table gains the route (objectstack-gatebucket, empty body), because a derived route with no entry fails the suite by name.packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts: the platform-admin/admin/sweep'sADMITTEDlist and payload table gain the route. Before that, the sweep failed by name on the new mount:POST /api/v1/auth/admin/list-platform-admins: expected [ Array(1) ] to deeply equal [](unclassified). The same file gainsC-28793, which pins the booted stack's answer: the platform admin's own id is on the roster, the plain-member target is not, andcountandentriesagree withadmins.The widening (
Clause-②: yes (widening)) is a new public route plus the new exportsresolveAdminUserIdsandADMIN_STANDING_PLATFORM_ENUMERATION. Nothing an existing caller relied on changed, so the level stayspatch.Tests
Package suites ran at head
6b5dd985(origin/main merged once); the two named dogfood runs below are at365488e5. Every run went throughos-verify-lock.pnpm --filter @objectstack/plugin-auth test: Test Files 212 passed (212), Tests 3655 passed, 10 skipped (3665).pnpm --filter @objectstack/platform-objects test: Test Files 109 passed (109), Tests 1507 passed (1507).pnpm --filter @objectstack/core test: Test Files 129 passed (129), Tests 2913 passed (2913).typecheckon the three packages: exit 0 (plugin-auth's test layer is held at its ledgered 88 errors and 23 signatures).packages/qa/dogfood, built dists of plugin-auth, platform-objects and core at this head):pnpm exec vitest run test/admin-route-nonadmin-refusal.dogfood.test.ts: Test Files 1 passed (1), Tests 7 passed (7).pnpm exec vitest run test/admin-platform-admin-standing.dogfood.test.ts: Test Files 1 passed (1), Tests 8 passed (8). Before this head's classification it was 1 failed (the unclassified-route assertion above).pnpm exec vitest runover the other files that sweep/admin/routes, the auth route ledger, orsys_useractions and api-action doors:route-ledger-live-mount-parity,discovery-auth-families,admin-ledger-decision-metadata,api-action-door-forward,mcp-system-object-action-exposure,mcp-oauth-api-action-forward,showcase-anonymous-deny-surfaces,admin-identity-audit-trail,admin-credential-lifecycle(each.dogfood.test.ts). Run together with the standing file at6b5dd985(no runtime source differs from365488e5; only the standing test and the changeset changed): Test Files 1 failed | 9 passed (10), Tests 1 failed | 147 passed (148). The 9 files account for all 141 of their tests passing, and the 1 failure was the standing file's unclassified-route assertion, which is fixed at this head.platform-admin-roster.pin.test.ts(12 tests, real ObjectQL on better-sqlite3 with the realhasPlatformAdminStanding),sys-user-platform-admin-roster-action.test.ts(4), and 4 classification tests inadmin-standing-surface.test.ts.Ablations (each restored, blob == HEAD and git diff HEAD empty)
The caller check in
runPlatformAdminRosterwas replaced withif (false). Four refusal cases went red,expected 200 to be 403(org owner, plain member, unverified owner address, unknown id).The
standing === 'platform-admins' ? [] :guard on the membership read was removed.the platform-admin population leaves an organization owner outwent red. The roster agreement stayed green, because the predicate confirmation drops the org owner, which is the second layer working. The first attempt was refused byablation-replace(the replacement was a substring of the anchor, so it did not land) and was redone with a distinct replacement.The owner-email half was disabled (
emails.length < 0). Five went red, including agreement (expected [ 'usr_grant' ] to deeply equal [ 'usr_grant', 'usr_owner' ]) and the sole-sourceOS_PLATFORM_OWNER_EMAILcase.sys_memberwas dropped fromnotCandidates. The core classification test went red (the declared list holdssys_member, the classified list does not).Cross-package: a third candidate
sys_ablation_third_sourcewas added tocandidateSources. Core was rebuilt, andablation-dist-preflightshowed the marker present in 2 built files. The plugin-auth pin went red:'sys_ablation_third_source' is a declared platform-admin candidate source with no fixture here: teach the enumerator …. On restore core was rebuilt, and the preflight--absentshowed the marker absent from all 14 built files with the tree clean.Live stack: the predicate confirmation in
resolvePlatformAdminRosterwas made unreachable (String(id) === 'ablation-28793-never' && …), and plugin-auth was rebuilt.ablation-dist-preflightfound the marker in 2 built files.admin-platform-admin-standing.dogfood.test.tswent red onC-28793only (1 failed, 7 passed):the roster omits the platform admin: {"success":true,"data":{"count":0,"admins":[],"entries":[]}}. On restore plugin-auth was rebuilt,--absentshowed the marker gone from all 20 built files, and the source blob was back to HEAD. A first attempt used a comment marker, which esbuild strips (the preflight reported it absent from dist), and-tskipped the identity control. Both were void readings and both were redone.Acceptance notes
ActionResultDialogwith this action'sresultDialogand the route's answer drew one list row per entry, with the code text equal toentries(ui/vitest, 1 passed; the file was deleted after the run). The rows are plain text with per-row copy and Copy all. They are not links to the user records, which would be a ui follow-up if wanted.hasPlatformAdminStanding. The fixture holds a Default Organization grant, a verified owner address, an unverified one, an expired grant, another organization's grant held by that organization's owner, and a plain member.sys_userfield and no read hook are added, and the list columns stay pinned insys-user-list-columns.test.ts.packages/core/src/security/index.ts(an export list), so expect at most a mechanical conflict there. No open PR toucheslast-admin-guard.ts,admin-standing-surface.ts,sys-user.object.tsor the route ledger.objectstack-gate(11 routes)) was already stale before this change (12 entries) and now reads 13. It was left alone as prose outside this diff's purpose.Verification
Local gate battery (dispatch-gates --commands, reconciled with --ran)
Derived at
6b5dd985: 72 families, 72 run.--ranreconciliation with the recorded exit codes: 71 run, 1 NOT-MEASURED, 0 UNRUN.node scripts/check-plugin-teardown-shape.mjs --self-testfirst exited 3 (PREREQUISITE NOT MET: the shallow clone cannot reach its pinned positive-control commit621a48760). After that one object was fetched it exited 0.pnpm check:dual-build-cjs-loads: the self-test passes (93 cases), then the scan exits 3 (PREREQUISITE NOT MET: ten packages outside this diff's build closure have nodist/,@objectstack/studio,client-reactand others). NOT MEASURED locally, because it needs a fullpnpm build. It is CI's reading (Lint & Repo Gates).Lint:
eslint --no-inline-configover the 16 touched ts/mjs files, exit 0.Generated by Claude Code