feat(api): RBAC - permission catalog, system roles, scoped grants, first-admin bootstrap #74
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!74
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/rbac"
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?
Summary
Implements #12 - roles and permissions (RBAC), ported from what the legacy code actually did.
What the legacy system really did (read from the code, not assumed):
RequireBackendRole,RequireAdministratorRole,RequireFinanceRole,RequireReportingRole). The 19 fine-grained admin permissions existed but were never enforced.HasPermissions) with roles stored as data, created per organization and assigned to an organization membership.What this PR does
admin_portal.access|administration.manage|finance.manage|reports.view). String keys replace numeric ids; the legacy id is kept for audit.AdminRoles reproduce the four legacy policies exactly (a test pins the role lists), plus Organization Administrator, Usher, Checker.roles,role_permissions,memberships,membership_roles); grants are scoped - platform scope applies everywhere, organization scope only to its own organization (HasInOrganization).Authorizerwith a per-user 30 s cache +Invalidate;Guard.Require(permission): 401 anonymous, 403 without (never names the permission), 500 on failure (nothing leaked).KWS_MODE=migratealso refreshes the system roles. New endpointsGET /v1/me/access,GET /v1/permissions(needsadministration.manage).KWS_BOOTSTRAP_ADMIN_EMAIL. The first user to sign in with that verified email becomes Super Admin, once, serialised by a DB advisory lock.Decisions to review ([verify] with the business)
...CustomerUpdatewas labelled "Create New Customer"). I ported by the label admins saw: view/create/update/delete (no "export"). Legacy controllers only ever checkedview.organization_idhas no FK yet; #37 (organizations) adds it.Test plan
Closes #12
🤖 Generated with Claude Code