Skip to content

Roles & Permissions

Role-based access control (RBAC) system with per-user permission overrides and security-level enforcement.

Overview

The Roles & Permissions module controls what each administrator can see and do within the platform. It implements a two-layer access control model:

  1. Roles define a baseline set of permissions shared by all users assigned to that role.
  2. Per-user overrides allow granting extra permissions (exceptions) or revoking specific permissions for individual administrators, without modifying the role itself.

A security level mechanism (1–3) restricts which users can assign or remove sensitive permissions, preventing privilege escalation.

Key Concepts

ConceptDescription
RoleNamed group of permissions with a security level (e.g. CSR, KAE, Admin)
PermissionAtomic right to view a section, perform an action, or see a menu item
Security levelNumeric tier (1, 2, 3) that gates who can grant/revoke a permission
InheritedPermission that comes from the user's assigned role
ExceptionPermission granted to a specific user outside the role's defaults
RevokedPermission denied for a specific user even though the role includes it

Data Flow

Permission Resolution

When the frontend loads, it fetches the administrator's effective permissions and uses them to build the sidebar menu and enable/disable UI actions.

Permission Assignment

When an admin assigns permissions to another user, the security level is validated server-side.

Database

Tables

TablePurpose
rolesRole definitions (name, security level, timestamps)
permissionsPermission definitions (name, module grouping, security level)
role_permissionsMany-to-many relationship between roles and permissions
admin_permissionsPer-administrator permission overrides (exceptions and revocations)
administratorsAdministrator records linking a user to a role, department, and office

Entity Relationships

Key Fields

  • roles.security_level: Determines the maximum permission security level that users with this role can assign. Value range: 1–3.
  • permissions.security_level: The minimum role security level required to assign or revoke this permission.
  • permissions.parent_id: Groups permissions into modules (parent = module header, children = individual permissions).
  • admin_permissions.action: 1 = granted (exception), -1 = revoked.
  • admin_permissions.is_inherited: true if the permission comes from the role, false if it's a per-user override.

Key Decisions

DecisionReasoningAlternatives Considered
Two-layer model (role + user overrides)Allows bulk permission management via roles while still handling individual exceptions without creating a new role per edge casePure role-based (no overrides), attribute-based access control (ABAC)
Numeric security levels (1–3)Simple to implement and understand; prevents lower-level admins from escalating privilegesFine-grained permission-on-permission system, hierarchical role inheritance
Server-side level validationFrontend disables switches as UX hint, but the API enforces the rule to prevent bypassFrontend-only enforcement
Permissions as flat list with parent groupingKeeps the database schema simple while allowing module-based grouping in the UINested permission trees, tag-based grouping

Dependencies

  • Internal: Authentication module (login, token validation), Sidebar/menu builder (reads permissions to render navigation)
  • External: None (self-contained RBAC system)

Envia Admin