Skip to main content

Role-Based Access Control (RBAC)

CORTEX implements a hierarchical RBAC system with three scope levels, permission inheritance, and time-bound role assignments.

Core Concepts

Roles

A role is a named collection of permissions. Roles can be organized in a hierarchy where child roles inherit permissions from parent roles.

Permissions

A permission represents the ability to perform a specific action on a specific resource. Permissions follow the resource:action pattern (e.g., users:create, organizations:read).

Role Assignments

A role assignment links a user to a role, optionally scoped to a specific organization and with an optional expiration date.

Scope Levels

┌─────────────────────────────────────────┐
│ PLATFORM Scope │
│ System-wide roles (e.g., SUPER_ADMIN) │
│ │
│ ┌────────────────────────────────────┐ │
│ │ TENANT Scope │ │
│ │ Tenant-wide roles │ │
│ │ (e.g., TENANT_ADMIN, MEMBER) │ │
│ │ │ │
│ │ ┌──────────────────────────────┐ │ │
│ │ │ ORGANIZATION Scope │ │ │
│ │ │ Org-specific roles │ │ │
│ │ │ (e.g., ORG_ADMIN, VIEWER) │ │ │
│ │ └──────────────────────────────┘ │ │
│ └────────────────────────────────────┘ │
└─────────────────────────────────────────┘
LevelDescriptionExample Roles
PLATFORMSystem-wide, across all tenantsSUPER_ADMIN
TENANTWithin a single tenantTENANT_ADMIN, MEMBER
ORGANIZATIONWithin a specific organizationORG_ADMIN, VIEWER

Role Hierarchy Example

TENANT_ADMIN (inherits all below)
├── ORG_ADMIN (inherits all below)
│ ├── MEMBER (inherits all below)
│ │ └── VIEWER (base permissions)

When a user has the TENANT_ADMIN role, they automatically inherit all permissions from ORG_ADMIN, MEMBER, and VIEWER.

Endpoints

MethodEndpointDescription
POST/rolesCreate role
GET/rolesList roles
GET/roles/:idGet role details
PATCH/roles/:idUpdate role
DELETE/roles/:idDelete role
GET/roles/:id/hierarchyGet role hierarchy tree
POST/permissionsCreate permission
GET/permissionsList permissions
POST/role-assignmentsAssign role to user
DELETE/role-assignments/:idRevoke role
GET/users/:id/rolesGet user's roles

Security Rules

  1. No Self-Escalation — Users cannot assign themselves a higher role
  2. No Cross-Tenant Roles — Roles from one tenant cannot be assigned in another
  3. Organization Scoping — ORG_ADMIN in Engineering cannot access Sales data
  4. Immutable System Roles — Built-in system roles cannot be modified or deleted