Repository navigation
feat(plugin-auth): import-users assigns positions from a positions column - #34531
Conversation
The positions column (position machine names, ;-separated, the spelling import-sso-users reads) is stripped before the write and assigned after runImport, each as a sys_user_position insert under the importing administrator's own execution context. An unresolved or refused position is a per-row outcome; the user is still created. Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
The Users import wizard offers the positions target column with a hint in every locale pack; the authentication guide documents the column and its per-row outcomes. Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
…tion grant The new sys_user_position insert in admin-import-users is one more engine write call site; the generated tables and the prose figures move by one. Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
…without a quote pair Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 24 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 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 ba87a50759b2776eaea0fc5e649fa67c0e959225 && git checkout ba87a50759b2776eaea0fc5e649fa67c0e959225
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1e4656d01fe485935c493a00ecdb8e0f8a0fed55 987b7e72531b18326315a7c2d6f77d8053af5c2a && git checkout -B drift-repro 1e4656d01fe485935c493a00ecdb8e0f8a0fed55 && git merge --no-ff 987b7e72531b18326315a7c2d6f77d8053af5c2a
node scripts/docs-audit/affected-docs.mjs --json 1e4656d01fe485935c493a00ecdb8e0f8a0fed55
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 first review · REWORK (1 item, docs only) · head REWORK
The open question in the report (whole-request 501 / 403 before any write)L1 reads option A as inside ruling 6920428750, not a new fork. The ruling's per-row clause covers a position that does not resolve or whose assignment is refused; a host with no grant seam, or a caller whose own access does not resolve, is known before the first write and would refuse every position on every row. A matches the sibling door: Checklist (read on GitHub at this head, not from the report)
Owed after this
NextL1 reads the delta only, on a head whose CI is green and announced final in a PR comment. |
… whole-file refusal Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
…tions per row, not the import Before the positions column the same file answered 200 and created every user, so a whole-request 501 or 403 narrowed the door. Every named position is now reported refused on its row (NOT_IMPLEMENTED, PERMISSION_DENIED) and the users land as before. Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
…efused per row, users still created Claude-Session: https://claude.ai/code/session_01ADHkmRNTuoSXYcZLxRV232 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review (r3): |
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Contract reviewServed-tier: The face is the declaration only: ① Derived judgments
② Semver levelClause-②: yes (widening) FROM, measured on ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 delta · ACCEPT · head My earlier judgment of option A is supersededIn 6934156935 I read option A (refuse the whole file Delta read (3 commits of the PR's own and two merges of
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Landing
Follow-ups filed and named in the body: #34535, #34536, #34537. Body note: the r1 "A" wording now says it was an L1 reading, not a ruling (body only, head unchanged). State: ready, auto-merge armed. |
Requested by Steve · project thread
Fixes #33113
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
POST /api/v1/auth/admin/import-users)新增一列positions(岗位机器名,多个用;分隔),用户建好后第二遍逐个指派岗位;控制台用户导入向导多了这一列和一句列说明。positions列的文件行为不变;岗位按管理员自己的权限写入,和 Setup 里指派岗位走同一套校验;回滚即还原本 PR。packages/plugins/plugin-auth/src/admin-import-users.ts的assignRowPositions与第二遍循环;同文件grantBlocked那段(缺 seam 或管理员自身上下文解析不出时,用户照建,只把每个岗位逐行记为被拒,code 分别是NOT_IMPLEMENTED/PERMISSION_DENIED);auth-plugin.ts新增的一行createGrant。pnpm --filter @objectstack/plugin-auth exec vitest run src/admin-import-users-manager-pass.test.ts -t positions,预期 13 例全绿。What changes
POST /api/v1/auth/admin/import-usersadmits one new column,positions, per the maintainer's ruling 6920428750 (verbatim: 「C,只加岗位列,p1」).positionsholds position machine names, several separated by;(an array on a JSON row). The name and spelling are the onesadmin/import-sso-usersalready reads (packages/plugins/plugin-auth/src/pending-sso-users.ts:188and:590onmain, documented atcontent/docs/permissions/authentication.mdx:1294), so one CSV shape serves both identity import doors. Reading of the ruling: 「只加岗位列」 limits the import to this one new column; it does not limit the column to one value, since a user may hold several positions and the sibling door's column already carries a list. The cell is parsed by the one reader both doors now import (name-list-cell.ts, moved out ofpending-sso-users.tsunchanged and not re-exported from the package index).manager_id. The cell is stripped before the identity write and assigned afterrunImportreturns, beside the manager pass, so every row of the batch exists.sys_user_positioninsert through the data engine under the importing administrator's own execution context, through thecreateGrantseam create-user and the pending doors already use (auth-plugin.tsgains one line wiring it into this mount). The position catalog refusal, the delegated-administration gate and the grant-holder membership refusal judge it as they judge Setup's form; none is re-derived in the importer.rows[].positionslists each named position withassigned,already_assigned(an upserted user who already holds it; nothing written),unresolved(the refusal is the catalog'sfields[].field === 'position'/reference_not_found) orrefused(any other refusal, with itscode). A cell that is not a list reads'unreadable'. The sentence ridesrows[].errorwhen free; norows[].codeis stamped, for the manager pass's documented reason.summary.positionscounts{ assigned, alreadyAssigned, unresolved, refused }, and the run-level audit row carries the same split. The import only adds positions.200, the answermaingives the same file) and every named position is reportedrefusedon its row, with codeNOT_IMPLEMENTED(no seam) orPERMISSION_DENIED(no context), counted undersummary.positions.refused; nothing is written tosys_user_position. Dry runs do not assign, and a dry run answers asmaindoes. The open question was first read as A at L1 review (refuse the whole file501/403before any write; a reading, not a ruling, and withdrawn in L1 comment 6936586013) and is now per row, because A narrowed the same input: onmainthat file answers200and creates the users (see Acceptance notes, FROM). Per row is also what ruling 6920428750 says of a position that cannot be assigned.demoStaffis untouched and stays development-only.positionsas a target column, and its options panel explains it (console.identityImport.positionsHint, added to all 11@object-ui/i18npacks, asall-locales-key-parityrequires).content/docs/permissions/authentication.mdx› Bulk Import Users documents the column and its outcomes, including that an unreadable cell'srows[].positionsis the string'unreadable'(counted undersummary.positions.unresolved), not an array, and that positions which cannot be judged at all are refused per row (NOT_IMPLEMENTED/PERMISSION_DENIED) while the users are still created.Tests
packages/plugins/plugin-auth/src/admin-import-users-manager-pass.test.ts: the existing harness gains an optional grant seam and asys_user_positioninsert double that refuses an unknown name the way the catalog refusal does and a denied one withPERMISSION_DENIED— only for non-system writes, so a system-context write would slip past it and fail the assertions. A new top-leveldescribeholds 13 cases: assignment under the administrator's context after the last create; CSV;parsing; unresolved per row with every other row landing; refused with the code;already_assignedon upsert; unreadable cell; the cell never reachingcreateUser; no seam needed without the column; a FROM control (the file measured onmain, on a host with no seam:200, both users created,summary.errors: 0, both rowsok); no seam → every named positionrefused/NOT_IMPLEMENTEDon its row, the row without the column untouched,summary.positions.refused: 3, nothing written; no context →refused/PERMISSION_DENIED, the user created andok; a dry run with no seam answers200with nothing written and no refusal; dry run assigns nothing.ui/packages/app-shell/src/views/__tests__/identityImportFields.emailRule-11913.test.tsx: a new top-leveldescribepins thepositionstarget column and the options-panel hint.sys_user_positiondouble; its existing cases are untouched.Acceptance notes
origin/maind4c0c12.main'sadmin-import-users.ts, driven with asys_userdeclaration reader and two rows carrying a non-emptypositionscell (sales_rep;sales_rep;area_manager), answered200,summary.created: 2,errors: 0, both rowsok: true/created, as JSON rows and as CSV;createUserreceived onlyemailandname. The dry run answered200, two rowscreated, nothing written. So onmainthe column is silently dropped and the users are created. Against that FROM this PR only widens: the column now assigns positions, and every input that answered200and created users onmainstill does. An earlier revision of this PR refused that file whole (501on a host with no grant seam,403when the caller's own context does not resolve), which narrowed the same input; that revision is withdrawn. Those two cases now create the users asmaindoes and report each named positionrefused(NOT_IMPLEMENTED/PERMISSION_DENIED) on its row; the FROM control test pins the200and the created users. HenceClause-②: yes (widening)with no(narrowing)arm.user.create.afterreconciler before the position is written. In multi-organization modeimport-usersdoes not join the importing admin's current organization (unlike create-user), so the grant-holder membership refusal answers each positionrefused/VALIDATION_FAILEDon its row; the user is still created. Filed: plugin-auth: admin import-users does not join created users to the importing admin's current organization in multi-org mode #34535.manager_idtarget column today, although the endpoint has admitted it since its own ruling; filed: console identity import wizard: nomanager_idcolumn to map, although import-users accepts a manager #34536.domain:skillscard, per the claim; filed: skills: teach thepositionscolumn of admin import-users #34537.already_assignedreads an existing hold by(user_id, position)regardless of organization, for upserted rows only.Verification
Targeted tests
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/admin-import-users-manager-pass.test.ts src/pending-sso-users.test.ts src/admin-import-users.test.ts→Test Files 3 passed (3),Tests 151 passed (151)(VERDICT command-exit 0, r3 head).pnpm --filter @objectstack/plugin-auth test→Test Files 280 passed (280),Tests 5780 passed | 10 skipped (5790)(r3 head).pnpm --filter @objectstack/plugin-auth typecheck→ exit 0;check:test-typecheck: OK(r3 head).ui:vitest runofidentityImport.test.ts,identityImportFields.emailRule-11913.test.tsx,identityImport.csvBatches-13315.test.tsxand all ofpackages/i18n/→Test Files 105 passed (105),Tests 1924 passed | 13 skipped(VERDICT command-exit 0, r1; r3 does not touchui/). The zh-Hant line is the generator's output (node scripts/gen-zh-hant.mjs), and the de line avoids a quote pair so thede-quote-pairingcount pin stays as it is.pnpm --filter @object-ui/i18n type-check && pnpm --filter @object-ui/app-shell type-check→ VERDICT command-exit 0.Ablations (each mutation landed on disk via scripts/ablation-replace.mjs, then restored to the HEAD blob)
SYSTEM_CTXinstead of the administrator's context → 3 cases red (the context assertion and the two refusal cases, since the checks stand down for system writes).return fail(501, 'NOT_IMPLEMENTED', …)when the file names positions and no seam is wired) → 2 red: the FROM control and the per-rowNOT_IMPLEMENTEDcase.if (grantBlocked && false)) → 2 red: theNOT_IMPLEMENTEDandPERMISSION_DENIEDcases.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 111 commands on head d3c32ee (r1), on the r2 head d69957c, and on the r3 head 987b7e7 (after the per-row change and a merge ofmain;packages/specwas rebuilt first because the merge moved its sources); each was run with stdin closed and its exit captured before any pipe: all 111 exit 0 on each head. On r3,pnpm --dir ui exec vitest run scripts/first exited 1 on one 15 s test timeout (check-i18n-call-site-keys.test.ts› main passes exactly the arguments…) while the plugin-auth full suite shared the box; the file alone then passed 152/152, and the whole family re-run on an idle box exited 0, which is the exit recorded.--ranreconciliation on each head:111 derived, 111 run, 0 NOT-MEASURED, 0 UNRUN.check:tenant-audit-censusfirst read the newsys_user_positioninsert as one more engine write call site (321 → 322); the generated tables were rewritten withnode scripts/tenant-audit-census.mjs --writeand the page's hand-written figures moved by one in the same commit (content/docs/permissions/tenant-audit-census.mdx,docs/audits/2026-08-tenant-audit-write-call-sites.counts.md). Every family CI runs is read from this PR's check runs.