Role-Based Access Control

Fine-grained permissions with RBAC

Rackd implements role-based access control (RBAC) for fine-grained permission management.

Overview

RBAC in Rackd follows the standard model:

  • Users - Accounts that can authenticate
  • Roles - Collections of permissions
  • Permissions - Fine-grained resource:action access controls

Users are assigned roles, and roles grant permissions. A user’s effective permissions are the union of all permissions from their assigned roles.

Default Roles

Rackd includes three built-in system roles that cannot be modified or deleted:

Admin

Full administrative access with all permissions. Can manage all resources including users, roles, and system configuration.

Operator

Operational access for day-to-day management:

ResourceActions
Deviceslist, create, read, update
Networkslist, create, read, update
Datacenterslist, read
Discoverylist, create, read

Cannot delete resources or manage users/roles.

Viewer

Read-only access to view resources:

ResourceActions
Deviceslist, read
Networkslist, read
Datacenterslist, read
Discoverylist, read

Permissions Reference

Devices

PermissionResourceActionDescription
device:listdeviceslistList all devices
device:createdevicescreateCreate new devices
device:readdevicesreadView device details
device:updatedevicesupdateModify devices
device:deletedevicesdeleteDelete devices

Networks

PermissionResourceActionDescription
network:listnetworkslistList all networks
network:createnetworkscreateCreate new networks
network:readnetworksreadView network details
network:updatenetworksupdateModify networks
network:deletenetworksdeleteDelete networks

Datacenters

PermissionResourceActionDescription
datacenter:listdatacenterslistList all datacenters
datacenter:createdatacenterscreateCreate new datacenters
datacenter:readdatacentersreadView datacenter details
datacenter:updatedatacentersupdateModify datacenters
datacenter:deletedatacentersdeleteDelete datacenters

Pools

PermissionResourceActionDescription
pool:listpoolslistList all IP pools
pool:createpoolscreateCreate new pools
pool:readpoolsreadView pool details
pool:updatepoolsupdateModify pools
pool:deletepoolsdeleteDelete pools

NAT

PermissionResourceActionDescription
nat:listnatlistList all NAT rules
nat:createnatcreateCreate NAT rules
nat:readnatreadView NAT rule details
nat:updatenatupdateModify NAT rules
nat:deletenatdeleteDelete NAT rules

Circuits

PermissionResourceActionDescription
circuits:listcircuitslistList all circuits
circuits:createcircuitscreateCreate circuits
circuits:readcircuitsreadView circuit details
circuits:updatecircuitsupdateModify circuits
circuits:deletecircuitsdeleteDelete circuits

Discovery

PermissionResourceActionDescription
discovery:listdiscoverylistList discovered devices
discovery:creatediscoverycreateStart discovery scans
discovery:readdiscoveryreadView discovery results
discovery:updatediscoveryupdateUpdate discovery settings
discovery:deletediscoverydeleteDelete discovered devices

Credentials

PermissionResourceActionDescription
credential:listcredentialslistList all credentials
credential:createcredentialscreateCreate credentials
credential:readcredentialsreadView credential details
credential:updatecredentialsupdateModify credentials
credential:deletecredentialsdeleteDelete credentials

Scan Profiles

PermissionResourceActionDescription
scan-profile:listscan-profileslistList all scan profiles
scan-profile:createscan-profilescreateCreate scan profiles
scan-profile:readscan-profilesreadView scan profile details
scan-profile:updatescan-profilesupdateModify scan profiles
scan-profile:deletescan-profilesdeleteDelete scan profiles

Scheduled Scans

PermissionResourceActionDescription
scheduled-scan:listscheduled-scanslistList all scheduled scans
scheduled-scan:createscheduled-scanscreateCreate scheduled scans
scheduled-scan:readscheduled-scansreadView scheduled scan details
scheduled-scan:updatescheduled-scansupdateModify scheduled scans
scheduled-scan:deletescheduled-scansdeleteDelete scheduled scans

Relationships

PermissionResourceActionDescription
relationship:listrelationshipslistList all relationships
relationship:createrelationshipscreateCreate relationships
relationship:readrelationshipsreadView relationship details
relationship:updaterelationshipsupdateModify relationships
relationship:deleterelationshipsdeleteDelete relationships

Conflicts

PermissionResourceActionDescription
conflict:listconflictslistList all conflicts
conflict:readconflictsreadView conflict details
conflict:detectconflictsdetectRun conflict detection
conflict:resolveconflictsresolveResolve conflicts
conflict:deleteconflictsdeleteDelete conflict records

Reservations

PermissionResourceActionDescription
reservation:listreservationslistList all reservations
reservation:createreservationscreateCreate reservations
reservation:readreservationsreadView reservation details
reservation:updatereservationsupdateModify reservations
reservation:deletereservationsdeleteDelete reservations

DNS Providers

PermissionResourceActionDescription
dns-provider:listdns-providerlistList all DNS providers
dns-provider:createdns-providercreateCreate DNS providers
dns-provider:readdns-providerreadView DNS provider details
dns-provider:updatedns-providerupdateModify DNS providers
dns-provider:deletedns-providerdeleteDelete DNS providers
dns-provider:testdns-providertestTest DNS provider connection

DNS Zones

PermissionResourceActionDescription
dns-zone:listdns-zonelistList all DNS zones
dns-zone:createdns-zonecreateCreate DNS zones
dns-zone:readdns-zonereadView DNS zone details
dns-zone:updatedns-zoneupdateModify DNS zones
dns-zone:deletedns-zonedeleteDelete DNS zones
dns-zone:syncdns-zonesyncSync DNS zone records
dns-zone:importdns-zoneimportImport DNS zone records

DNS Records

PermissionResourceActionDescription
dns:listdnslistList all DNS records
dns:creatednscreateCreate DNS records
dns:readdnsreadView DNS record details
dns:updatednsupdateModify DNS records
dns:deletednsdeleteDelete DNS records
dns:syncdnssyncSync DNS records
dns:importdnsimportImport DNS records

Users

PermissionResourceActionDescription
user:listuserslistList all users
user:createuserscreateCreate new users
user:readusersreadView user details
user:updateusersupdateModify users
user:deleteusersdeleteDelete users

Roles

PermissionResourceActionDescription
role:listroleslistList all roles
role:createrolescreateCreate custom roles
role:readrolesreadView role details
role:updaterolesupdateModify roles
role:deleterolesdeleteDelete custom roles

API Keys

PermissionResourceActionDescription
apikey:listapikeyslistList API keys
apikey:createapikeyscreateCreate API keys
apikey:readapikeysreadView API key details
apikey:updateapikeysupdateModify API keys
apikey:deleteapikeysdeleteDelete API keys

Webhooks

PermissionResourceActionDescription
webhooks:listwebhookslistList all webhooks
webhooks:createwebhookscreateCreate webhooks
webhooks:readwebhooksreadView webhook details
webhooks:updatewebhooksupdateModify webhooks
webhooks:deletewebhooksdeleteDelete webhooks

Custom Fields

PermissionResourceActionDescription
custom-fields:listcustom-fieldslistList all custom fields
custom-fields:createcustom-fieldscreateCreate custom fields
custom-fields:readcustom-fieldsreadView custom field details
custom-fields:updatecustom-fieldsupdateModify custom fields
custom-fields:deletecustom-fieldsdeleteDelete custom fields

Audit Logs

PermissionResourceActionDescription
audit:listauditlistView audit logs
PermissionResourceActionDescription
search:readsearchreadSearch across resources

Dashboard

PermissionResourceActionDescription
dashboard:readdashboardreadView dashboard

Managing Roles

CLI Commands

# List roles
rackd role list

# List available permissions
rackd role permissions

# Filter permissions by resource
rackd role permissions --resource devices

# Create a custom role
rackd role create --name "Network Admin" --description "Full network management"

# Assign role to user
rackd role assign --user-id user-123 --role-id role-456

# Revoke role from user
rackd role revoke --user-id user-123 --role-id role-456

# Delete a custom role
rackd role delete --id role-456

Web UI

  1. Navigate to Settings → Roles
  2. View existing roles and their permissions
  3. Create custom roles with specific permission sets
  4. Assign roles to users from the user management page

API Endpoints

Roles

MethodEndpointDescription
GET/api/rolesList roles
GET/api/roles/{id}Get role details
POST/api/rolesCreate role
DELETE/api/roles/{id}Delete role

Permissions

MethodEndpointDescription
GET/api/permissionsList permissions

User Role Assignment

MethodEndpointDescription
POST/api/users/grant-roleAssign role to user
POST/api/users/revoke-roleRevoke role from user

Permission Checking

In Code

Permissions are checked at the service layer using the requirePermission function:

func (s *DeviceService) Create(ctx context.Context, device *model.Device) error {
    if err := requirePermission(ctx, s.checker, "devices", "create"); err != nil {
        return err
    }
    // ... create device
}

For API Keys

API keys inherit permissions from their owning user. When an API key makes a request:

  1. The system resolves the user associated with the API key
  2. Checks the user’s roles and permissions
  3. Allows or denies the action based on permissions

For OAuth Tokens (MCP)

OAuth tokens can be scoped to specific permissions. The token’s scope restricts what actions can be performed, even if the user has broader permissions.

Best Practices

  1. Principle of Least Privilege - Assign only the minimum required permissions
  2. Use Built-in Roles - Start with viewer/operator before creating custom roles
  3. Regular Audits - Periodically review role assignments
  4. Document Custom Roles - Maintain clear descriptions of custom role purposes
  5. Separate Duties - Use different roles for different operational areas