Admin API: roles, users and role assignment (#44 follow-up) #133
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #44. The admin portal can review organizations (PR #131) but there is no API to manage roles, users or role assignment: roles are built-in data (
rbac.SystemRoles(), re-applied byKWS_MODE=migrate) and memberships are only created by the organization flows, the bootstrap admin (KWS_BOOTSTRAP_ADMIN_EMAIL) and API keys. Staff cannot be given or lose a role without SQL.Scope
Admin routes under
/v1/admin, platform scope only (rbac.PlatformOnly), permissionadmin_portal.administration.manage([verify] whether a separateadmin_portal.users.managekey is wanted):GET /v1/admin/permissions: the permission catalog (key, application, description) so a role editor can list choices.version), delete (custom roles only; system roles read-only; a role in use is a 409). Tables exist:roles,role_permissions.memberships,membership_roles.Rules to carry over
last_administrator-style, locked like members in ADR 0021).postgres.InTxandaudit_attachon the touched tables; edit conflicts byversion(409);Idempotency-Keyon create; callAuthorizer.Invalidateafter a change (other nodes catch up within the 30 s TTL).ratelimit.PatternsandTooManyRequestsin the OpenAPI operations.operationId/tag/security/statuses and live contract test calls (make contract); TDD;make cover>= 80%; regenerate clients.Decisions (owner, 2026-10-30)
admin_portal.administration.manage) can deactivate a user or remove their membership. Deactivating is a real state on the user (a deactivated user is refused at sign-in/authorizer with the same 401/403 as no access); removing the platform membership drops their roles. Decided: a real state on the user (new migration:users.deactivated_at timestamptz+deactivated_by uuid REFERENCES users(id), audited, never blocks reading history). A deactivated user is refused by the authenticator/authorizer like a user with no access (same fixed 401/403), loses nothing else (roles stay, so reactivating restores access), and cannot be the last active Super Admin (409). Deactivate/reactivate are admin-only routes withversion.orgs.Inviter/orgs.Membersalready exist).admin_portal.administration.manageto invite,Idempotency-Keyon create, expiry job, and the same "inviter must still hold the permission at accept time" rule. Deleting an unaccepted invitation is allowed.Blocks the web pages in the issue "Admin: roles, users and role assignment pages".
Status 2026-10-31: slice A (PR #135) and slice B staff invitations (PR #136) are merged. Against a real local Zitadel the first admin flow found that Zitadel JWT access tokens carry no email, so bootstrap and invitation matching never fired; fixed in PR #139 (email read from the userinfo endpoint). Customers who sign in to the admin portal now see a no-access page (PR #140). Still untried against a real IdP: the staff invitation email and accept, and the prompt=create sign-up (needs a local mail catcher). Left open: the owner decides when to close. Deployment checklist (not yet a PR) is on branch docs/deployment-checklist.