Repository navigation
feat(admin): allow one admin or several, and hand the admin role over (D1) - #491
Merged
Merged
Conversation
An admin chooses whether the install allows one admin or several. With one, adding an admin, promoting one or reactivating an old admin is refused (409) while an active admin exists; Make admin hands the role over in one UPDATE, the previous admin becoming an owner. New installs and installs with a single admin default to one; installs that already have several keep several. FOX_ADMIN_POLICY=one|several overrides it. Switching to one is refused while several admins are active, and the error names them. Also adds the workspaces plan (D1 of docs/plans/2026-10-09-workspaces- and-admin-policy.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: e30cb660-e419-47eb-b2c0-b018ebe6840e) |
Contributor
Test IDsAdded (5)
|
This was referenced Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
D1 of the workspaces plan, which this PR also adds.
What changes
RbacModule/AuthModule.insertUser, so every caller hits it.UPDATE … CASE; the previous admin becomes an owner.FOX_ADMIN_POLICY=one|severaloverrides it and makes the control read-only.GET/PUT /api/admin/policy,POST /api/admin/users/:id/transfer-admin(added to the HTTP contract table, 116 → 119).Tests
admin-policy.service.test.ts(23): defaults, each gate, switching, transfer. Each gate was A/B-checked: removing it fails its test.admin-policy.test.ts, run against the dev server: 3 passed, the one-policy case skipped because the dev DB has several admins.Review
Self-review fixed: a 403 banner after a successful transfer, the success message not shown on App users, re-saving Active on an active admin being refused, and hint wording. Left as is: a transfer to an invited account (SSO accounts never set a password, so blocking it would block them), and a check-then-write race (the metadata store has no transactions).
🤖 Generated with Claude Code
Note
High Risk
Changes authorization and admin-account lifecycle (role promotion, reactivation, transfer) with security-sensitive 409 behavior; a noted check-then-write race remains without DB transactions.
Overview
Adds an install-wide one admin vs several policy (D1 from the new workspaces plan doc), wired through server enforcement, admin UI, and tests.
Server:
auth.admin_policyis read/written viaGET/PUT /api/admin/policy, withFOX_ADMIN_POLICYoverride and a one-time startup backfill (onefor ≤1 active admin,severalif more). Under one,assertAdminSlotFreeblocks creating/promoting/reactivating a second admin (409 viaAdminPolicyError).POST /api/admin/users/:id/transfer-adminatomically promotes another user and demotes the caller (defaultowner).Web: App users shows Admins: One / Several, disables direct admin role picks when the slot is taken, and under one shows Make admin (hand-over with confirm) instead of promotion; env-locked policy is read-only.
Tests: New server suite, component/helper coverage, e2e
admin-policy.test.tsin the full e2e runner, HTTP contract count 116→119, and newdata-testids.Reviewed by Cursor Bugbot for commit fb2ed79. Bugbot is set up for automated code reviews on this repo. Configure here.