feat: implement fine-grained RBAC service with support for role hierarchy, temporary elevation, and audit logging.#530
Merged
Smartdevs17 merged 1 commit intoJun 2, 2026
Conversation
…rchy, temporary elevation, and audit logging.
|
@Dubemtopsite Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Description
Implements comprehensive Role-Based Access Control (RBAC) with a fine-grained permission model. Replaces the previous basic access checks with a structured admin / manager / viewer role hierarchy, each with resource-level permissions across 13 resource types.
Changes
New:
backend/services/accessControl.tsadmin,manager,viewer) with explicit permissions per resource. Role hierarchy with strict ordering (admin > manager > viewer) and no duplicate levels.hasPermission(userId, resource, action)andrequirePermission(userId, resource, action)that throwsAccessDeniedErroron denial.assignRole,revokeRole,getAssignment,getUserRolewith automatic audit logging via the existingAuditService. System bootstrap viabootstrap()for initial admin seeding.registerApiKeyScope/checkApiKeyPermission/updateApiKeyScopefor binding fine-grained permission sets to API keys, with optional resource allow-lists and rate limits.UnauthorizedAccessEvent. Tracks stats by actor/resource. Dispatches alerts viaAlertingServicewhen any actor accumulates 5+ unresolved denials.grantTemporaryElevationwith configurable TTL. Tracks original vs elevated role for full auditability.preventEscalation()throwsPermissionEscalationErrorwhen an actor attempts to assign a role equal to or higher than their own.Modified:
backend/services/index.tsAccessControlService,AccessDeniedError,PermissionEscalationError,ROLE_PERMISSIONS,ROLE_HIERARCHY, and all related types.Modified:
src/components/admin/FeatureManagement.tsxuserRoleandcurrentUserIdprops for RBAC integration.requirePermission()— non-admin users see an "Access Denied" alert.disabledfor non-admin users.New:
backend/services/__tests__/accessControl.test.tsNew:
docs/permissions.mdAcceptance Criteria
Technical Scope
accessControl.tswith full RBAC implementationpreventEscalation()with strictcanAssignRole()guardvalidateRoleHierarchy()ensures no duplicate levels and valid orderingTesting
Closes #420