Feature Specification: RBAC & Permissions
1. Overview & Vision
RBAC (Role-Based Access Control) is the platform's governance engine. It ensures that every action taken by a user or service is authorized based on a centralized set of policies, providing organization-level control over sensitive data and features.
2. Personas & Stakeholders
| Persona | Goal |
|---|---|
| Org Admin | Define custom roles and assign permissions to team members. |
| Member | Perform authorized tasks without encountering security barriers. |
| System Admin | Define global system roles and monitor policy compliance. |
3. User Stories
- As an admin, I want to create a "Finance Manager" role that can view invoices but not change HR records.
- As an admin, I want to temporarily suspend all permissions for a user without deleting their account.
4. Functional Requirements (FR)
- REQ-RBAC-001: Support for custom role definitions per organization.
- REQ-RBAC-002: Centralized permission registry for all satellite apps.
- REQ-RBAC-003: Real-time permission checking via Casbin.
- REQ-RBAC-004: Inherited roles (e.g.,
admininherits allmemberpermissions).
5. Non-Functional Requirements (NFR)
- Latency: Permission check < 10ms (cached in Redis).
- Auditability: Every permission change MUST be logged in the audit trail.
6. Business Logic & Rules
- Subject-Object-Action (SOA): Policies follow the Casbin model:
p, sub, obj, act. - Default Roles: Every new organization is provisioned with
Owner,Admin, andMember. - Scope: Permissions can be scoped to a specific satellite module (e.g.,
drive:*).
7. User Interface (UI/UX)
- "Roles & Permissions" editor with a matrix-style checkbox grid.
- User-to-Role assignment interface with bulk management.
- Visual indicators for inherited vs. explicitly granted permissions.
8. Information Architecture
- Located under "Organization Settings" in the Shell.
- Grouped by satellite module for clarity.
9. Data Model & Persistence
- Tables:
roles,permissions,role_permissions,user_roles. - Engine: Casbin with PostgreSQL adapter.
10. API & Service Layer
GET /api/rolesPOST /api/roles/:id/permissionsRbacService.CheckPermission(gRPC)
11. Integration Patterns
- Satellite apps perform remote permission checks via the Shell gRPC gateway.
- Declarative
@authorize()decorators in satellite controllers.
12. Security & Permissions
- Only
OwnerorAdmincan modify roles. - Cross-tenant role assignment is strictly prohibited.
13. Error Handling & Resilience
- Graceful
403 Forbiddenresponses with a description of the missing permission. - Fallback to "Deny All" if the Casbin engine fails.
14. Performance & Scalability
- Enforcer policies are cached in Redis for fast evaluation.
- Local policy caching in satellite modules (planned for v1.2).
15. Globalization & i18n
- Permission names and descriptions are localized (EN/VI).
16. Accessibility (a11y)
- Accessible permission grid (keyboard navigation, high contrast).
17. Observability & Analytics
- Tracking of "Denied Actions" to identify potential security threats or UX friction.
18. Testing & Quality
- Policy unit tests to ensure
Adminalways has full access. - Negative tests to verify data isolation.
19. Constraints & Assumptions
- Assumes satellite apps correctly define their own permission codes in the Shell registry.
20. Future Enhancements
- Resource-based permissions (e.g., "Access only to Folder X").
- Time-bound role assignments (temporary permissions).