RBAC Overview
RBAC Overview
Section titled “RBAC Overview”Role-Based Access Control (RBAC) in Mantis provides granular security for all system resources.
Overview
Section titled “Overview”Key Concepts
Section titled “Key Concepts”Users are individual accounts that can authenticate to Mantis. Each user:
- Has an email and username unique within its tenant
- Can be assigned one or more roles
- May be scoped to a specific tenant
- Can authenticate via local credentials or external identity providers
Roles are named groups of permissions. Mantis includes system roles:
| Role | Description |
|---|---|
admin | Full system access with all permissions (protected) |
operator | Deployment and target management (protected) |
viewer | Read-only access to resources (protected) |
tenant_admin | Full access within assigned tenant. Seeded but is_system = false, so it is not protected — holders of roles:update/roles:delete can modify or delete it. |
Custom roles can be created to match your organizational needs.
Permissions
Section titled “Permissions”Permissions grant specific actions on resources. Format: resource:action
| Component | Examples |
|---|---|
| Resource | deployments, targets, actions, users |
| Action | create, read, update, delete |
Example permissions:
deployments:create- Start new deploymentstargets:read- View target informationusers:delete- Remove user accounts
Permission Model
Section titled “Permission Model”Permission Inheritance
Section titled “Permission Inheritance”Users receive permissions through their roles:
User → Roles → PermissionsIf a user has multiple roles, they receive the union of all permissions:
Authorization Flow
Section titled “Authorization Flow”Permission Checking
Section titled “Permission Checking”Every protected endpoint validates permissions:
// In handlercheck_permission(&mut conn, audit, &auth.claims, "deployments:create").await?;The check:
- If the caller authenticated with an API key, the key’s own scopes must cover the permission first — a key whose owner has the permission still gets 403 (“API key lacks required scope”) if the key’s scopes are narrower.
- Extracts
user_idfrom JWT claims - Queries database for user’s permissions via roles
- Returns success or logs denial to audit
System Roles
Section titled “System Roles”Full system access:
- All permissions across all resources
- Cannot be modified or deleted
- Typically assigned to platform administrators
Operator
Section titled “Operator”Deployment operations:
- Create, read, update actions/sequences/solutions
- Create and manage deployments
- Register and manage targets
Viewer
Section titled “Viewer”Read-only access:
- View deployments and their status
- View targets and environments
- View actions, sequences, solutions
- Cannot make any modifications
Tenant Admin
Section titled “Tenant Admin”Full access within tenant scope:
tenant_adminholds every permission except these nine:tenants:create- Cannot create new tenantstenants:delete- Cannot delete tenantssystem:admin- No system administrationsettings:manage- Cannot modify system settingsaudit:read- Cannot read audit logsdeployments:update- Cannot modify deploymentsdeployments:trigger- Cannot trigger deploymentsdeployments:override_freeze- Cannot override a deployment freezewireguard:manage- Cannot manage the WireGuard overlay
- The authoritative check is the
roles_permissionsjoin, not this list: every permission migration decides thetenant_admingrant explicitly, so the set moves. The seed excludes a different set from the one in force today — theschedules:*permissions it withholds were granted back later, and the four admin-only permissions above were added afterwards. - Delegation is secure by default: when a
tenant_admin(or any non-system-admin) assigns roles/permissions, it may confer only permissions it itself holds or ones carried by the baselineviewer/operatorroles. Everything else — including any future system-tier permission — is refused. See Permissions → Tenant Admin Role for details. - Ideal for delegated tenant management
Multi-Tenant Context
Section titled “Multi-Tenant Context”When a user has a tenant_id:
- Handlers apply tenant scoping explicitly (via
resolve_tenant_scope/effective_tenant_scope); several list endpoints resolve to own-tenant or global (tenant_id IS NULL), not own-tenant only - User can only access resources within their tenant
- Cross-tenant access returns 404 (not 403) to prevent enumeration
Best Practices
Section titled “Best Practices”Principle of Least Privilege
Section titled “Principle of Least Privilege”Assign the minimum permissions required:
Role Hierarchy Strategy
Section titled “Role Hierarchy Strategy”Create roles matching your organization:
| Level | Example Roles | Typical Permissions |
|---|---|---|
| Platform | admin, auditor | Full access, read all |
| Operations | operator, deployer | Deployment management |
| Read-only | viewer, support | View resources |
| Custom | env-prod-admin | Specific environment access |
Audit Compliance
Section titled “Audit Compliance”Authorization denials are logged (successful checks are not):
{ "event_type": "authz.permission_denied", "event_category": "authorization", "severity": "security", "actor_type": "user", "actor_id": "019b937d-4862-8e07-ac3a-1b8589d1b807", "actor_name": "alice", "action": "check_permission", "outcome": "denied", "outcome_reason": "Insufficient permission", "occurred_at": "2026-01-15T14:23:01"}Configuration
Section titled “Configuration”API Endpoints
Section titled “API Endpoints”| Endpoint | Description |
|---|---|
GET /api/v1/admin/users | List users |
GET /api/v1/admin/roles | List roles |
GET /api/v1/admin/permissions | List permissions |
POST /api/v1/admin/roles/{id}/permissions | Assign permissions |
POST /api/v1/admin/users/{id}/roles | Assign roles |
Required Permission to Manage RBAC
Section titled “Required Permission to Manage RBAC”| Action | Permission |
|---|---|
| View users | users:read |
| Create users | users:create |
| Modify users | users:update |
| Delete users | users:delete |
| List/view roles | roles:manage |
| Create roles | roles:create |
| Modify roles | roles:update |
| Assign/remove permissions | roles:manage |
Troubleshooting
Section titled “Troubleshooting”User Cannot Access Resource
Section titled “User Cannot Access Resource”-
Check user’s assigned roles:
Terminal window curl -s -H "Authorization: Bearer $TOKEN" \https://api.mantis.local/api/v1/admin/users/$USER_ID/roles -
Check role’s permissions:
Terminal window curl -s -H "Authorization: Bearer $TOKEN" \https://api.mantis.local/api/v1/admin/roles/$ROLE_ID/permissions -
Verify required permission for endpoint
Permission Denied Despite Having Role
Section titled “Permission Denied Despite Having Role”- Verify the user-role assignment exists (
users_roleshas no active/expiry column — an assignment either exists or it does not) - Check if permission is assigned to the role
- Review audit logs for specific denial reason
Next Steps
Section titled “Next Steps”- Users - User management
- Roles - Role configuration
- Permissions - Permission reference
- Tenant Isolation - Multi-tenant access control
