Skip to main content
Sign in →

Roles & Permissions (RBAC)

ShieldAgent enforces role-based access control on every API endpoint. This page documents the built-in roles, the permission matrix, and the exact permission required by each endpoint.

Overview

Every authenticated request is checked against the caller's role within the target tenant. Permissions follow a resource:action pattern (e.g. agent:write). Platform admins bypass tenant scoping and have all permissions. Tenant-scoped roles are assigned per-tenant, so a user can be an auditor in one tenant and a tenant_admin in another.

The permission cache has a 60-second TTL with graceful degradation — if the database is temporarily unreachable, stale permissions are served rather than denying access.

Built-in Roles

ShieldAgent ships with six system roles. Custom roles are not yet supported — assignments use these built-in roles.

RoleScopeDescription
platform_adminPlatformFull platform access across all tenants. Reserved for ShieldAgent operators.
tenant_adminTenantFull management of one tenant: users, settings, billing, all sub-resources.
security_operatorTenantMonitoring, incident triage, alert management, risk review.
auditorTenantRead-only access to compliance reports, audit trail, and export.
aiops_engineerTenantAgent lifecycle, MCP server/binding config, policy authoring.
viewerTenantRead-only dashboard and summary data.

Permission Matrix

The matrix below shows every permission and which roles include it. platform_admin and tenant_admin have all permissions and are omitted for readability.

PermissionDescriptionsec_opauditoraiopsviewer
agent:readView / list agents
agent:writeCreate or update agents
agent:deleteRemove agents
agent:configureModify agent settings / baselines
policy:readView / list policies
policy:writeCreate or update policies
policy:deleteRemove policies
audit:readView audit trail events
audit:exportExport audit data
compliance:readView compliance reports
compliance:writeCreate or update compliance records
compliance:exportExport compliance data
risk:readView risk scores and trending
risk:configureModify risk thresholds / overrides
incident:readView incidents
incident:writeCreate or update incidents
incident:triageAcknowledge, assign, or resolve
mcp_server:readView MCP server registrations
mcp_server:writeCreate or update MCP servers
mcp_server:deleteRemove MCP servers
alert:readView alerts
alert:writeCreate or update alert rules
alert:deleteRemove alert rules
alert:triageAcknowledge or resolve alert events
review:readView pending reviews
review:triageApprove or reject reviews
user:readView user accounts
user:writeCreate or update users and roles
user:deleteRemove user accounts
tenant:readView tenant settings
tenant:writeModify tenant settings / billing
export:readView export configurations
export:writeCreate or update export configs
dashboard:readView aggregated dashboard data

Endpoint Auth Requirements

Every tenant-scoped endpoint requires a valid JWT plus the listed permission. The middleware validates both tenant membership and the specific permission before the handler runs. A 403 Forbidden is returned if the check fails.

Agents

MethodPathPermission
GET/tenants/:tenantId/agentsagent:read
POST/tenants/:tenantId/agentsagent:write
PUT/tenants/:tenantId/agents/:agentIdagent:write
PATCH/tenants/:tenantId/agents/:agentIdagent:configure
DELETE/tenants/:tenantId/agents/:agentIdagent:delete

Policies

MethodPathPermission
GET/tenants/:tenantId/policiespolicy:read
POST/tenants/:tenantId/policiespolicy:write
PUT/tenants/:tenantId/policies/:policyIdpolicy:write
DELETE/tenants/:tenantId/policies/:policyIdpolicy:delete

Audit Trail

MethodPathPermission
GET/tenants/:tenantId/auditaudit:read
GET/tenants/:tenantId/audit/verify-chainaudit:read

Compliance

MethodPathPermission
GET/tenants/:tenantId/compliance/reportcompliance:read
GET/tenants/:tenantId/compliance/controlscompliance:read
POST/tenants/:tenantId/compliance/versionscompliance:write

Incidents

MethodPathPermission
GET/tenants/:tenantId/incidentsincident:read
POST/tenants/:tenantId/incidentsincident:write
PATCH/tenants/:tenantId/incidents/:incidentIdincident:triage

Users & Tenants

MethodPathPermission
GET/tenants/:tenantId/usersuser:read
POST/tenants/:tenantId/users/inviteuser:write
PATCH/tenants/:tenantId/users/:userIduser:write
GET/tenants/:tenantIdtenant:read
PUT/tenants/:tenantIdtenant:write

Middleware Usage

Route handlers attach RBAC checks as Fastify preHandler hooks. Two variants are available:

requireTenantPermission(...perms)

Validates that the caller belongs to the tenant in :tenantId and holds at least one of the listed permissions. Used by all tenant-scoped endpoints.

typescript
fastify.get(
  '/tenants/:tenantId/agents',
  { preHandler: [authenticate, rbac.requireTenantPermission('agent:read')] },
  async (request, reply) => { /* handler */ }
);

requirePermission(...perms)

Checks the permission without tenant scoping. Used for platform-level endpoints like policy templates or billing plan listing.

typescript
fastify.get(
  '/policy-templates',
  { preHandler: [authenticate, rbac.requirePermission('policy:read')] },
  async (request, reply) => { /* handler */ }
);

Public Endpoints

A small number of endpoints bypass authentication entirely:

POST/auth/signupCreate a new account
POST/auth/loginAuthenticate and receive JWT
GET/healthLiveness probe (no rate limiting)

Role Assignment

Roles are assigned per user per tenant via the user_roles table. A user can hold different roles in different tenants. Assignments track who granted the role and support optional expiration.

typescript
// Assign a role via the API
PATCH /tenants/:tenantId/users/:userId
{
  "role": "security_operator"
}
// Requires: user:write permission

Legacy role values (admin, tenant) are automatically normalized to their RBAC equivalents (platform_admin, tenant_admin) at middleware level.

Roles & Permissions (RBAC)