RBAC management Akira
Source of truth
RBAC must stay coherent across:
docs/security/rbac-matrix.mdrole-permission matrix.apps/backend/src/akira_backend/core/rbac_loader.pyconstants.- Static frontend permission gates in
apps/frontend.
Run drift detection before merging RBAC changes:
scripts/audit_rbac.py
Expected clean result:
[rbac-audit] OK: zero drift
Adding a permission
- Add the permission row in
docs/security/rbac-matrix.md. - Add the permission to
ALL_PERMISSIONSinrbac_loader.py. - Add role grants to
ROLE_GRANTSmatching the matrix. - Protect backend routes with
@require_permission("<module>.<action>"). - Gate frontend flows with the same static permission key when needed.
- Run
scripts/audit_rbac.py.
Removing a permission
- Audit backend route decorators and frontend gates before removing it.
- Remove the permission from the matrix and
rbac_loader.pyin the same change. - Remove or replace frontend gates that reference it.
- Update RBAC seed or migration logic if the database needs cleanup.
- Run
scripts/audit_rbac.py.
Drift categories
STALE_DOC: permission appears in the matrix but not in the loader.MISSING_DOC: permission appears in the loader but not in the matrix.ORPHAN_FRONTEND: frontend gate references a permission absent from the loader.INCOMPLETE_ROLE: matrix contains a role missing from loader grants.STALE_DOC_ROLE_GRANT: matrix grants a role-permission pair absent from loader grants.MISSING_DOC_ROLE_GRANT: loader grants a role-permission pair absent from the matrix.
Fix drift in the same pull request that changes RBAC so the role seed and UI gates remain auditable.