Role-Based Access Control (RBAC) requires an Enterprise Edition license.
Overview
Free vs. Enterprise
Free Edition:- All authenticated users have full access
- No permission restrictions
- Single “Admin” concept (all users are admins)
- Fine-grained permissions per resource type
- Custom roles with specific permission sets
- Environment-scoped roles
- Admin role controls system-wide access
Permission Model
Resources
Dockhand permissions are organized by resource type:- containers - Docker containers
- images - Docker images
- volumes - Docker volumes
- networks - Docker networks
- stacks - Docker Compose stacks
- environments - Environment connections
- registries - Registry credentials
- notifications - Notification channels
- configsets - Configuration templates
- settings - Global settings
- users - User management
- git - Git repositories and stacks
- license - License management
- audit_logs - Audit log viewing
- activity - Activity dashboard
- schedules - Scheduled tasks
Actions
Each resource supports different actions:- view - Read access (list, view details)
- create - Create new resources
- edit - Modify existing resources
- delete - Remove resources
- execute - Special actions (start, stop, restart containers)
Permission Format
Built-in Roles
Dockhand includes two system roles:Admin Role
Full access to all resources and actions:Viewer Role
Read-only access to most resources:Managing Roles
List Roles
Create Role
Update Role
Delete Role
Assigning Roles to Users
Assign Role
- roleId: ID of the role to assign
- environmentId: Scope to specific environment (optional,
null= all)
Assign Environment-Scoped Role
List User Roles
Remove Role
Environment-Scoped Roles
Concept
Roles can be scoped to specific environments:- Global Role (
environmentId: null) - Applies to all environments - Scoped Role (
environmentId: 3) - Applies only to environment 3
Example Scenario
User: AliceRoles:
- “Docker Operators” (global) - Manage containers everywhere
- “Dev Team” (environment 5) - Full access to dev environment
- Production (env 1): Docker Operators permissions (view, create containers)
- Staging (env 2): Docker Operators permissions
- Development (env 5): Merged Docker Operators + Dev Team permissions
Role Merging
When a user has multiple roles for an environment, permissions are merged (union):Environment Access Control
Roles withenvironmentIds restrict access:
Common Role Examples
Container Operator
Manage containers but not delete:Stack Manager
Deploy and manage stacks:Environment Admin
Full access to a specific environment:Security Auditor
View-only access plus audit logs:Permission Checking
API Enforcement
Every API endpoint checks permissions:Environment Context
Check permissions for a specific environment:UI Hiding
The UI hides actions the user cannot perform:LDAP/OIDC Integration
Automatic Role Assignment
LDAP and OIDC providers can map groups to roles: OIDC Example:Role Sync
Roles are synced on every login:- User logs in via LDAP/OIDC
- Dockhand checks group memberships
- Assigns roles for groups user is in
- Removes roles for groups user is no longer in
- Keeps local roles (not managed by IdP) unchanged
Database Schema
Roles Table
User Roles Table
Authorization Service
Dockhand provides a centralized authorization service:src/lib/server/authorize.ts for full details.
Best Practices
Role Design
- Start broad, refine later - Begin with Admin/Viewer, add custom roles as needed
- Group by job function - “Docker Operators”, “Security Team”, not “Alice’s Role”
- Use environment scoping - Separate prod/staging/dev access
- Avoid user-specific roles - Roles should apply to multiple users
Permission Granularity
- Balance security vs. usability - Don’t over-complicate
- View permission is usually safe - Most users should see most resources
- Restrict delete carefully - Production data should be protected
- Settings need edit permission - Otherwise users can’t configure anything
Admin Role
- Keep Admin count low - 2-3 admins for small teams
- Use environment-scoped roles - Don’t give everyone global admin
- Audit admin actions - Enable Enterprise audit logging
- Have a backup local admin - In case LDAP/OIDC fails
Environment Strategy
- Scope sensitive environments - Production should be restricted
- Dev environments can be open - Let developers experiment
- Use global roles for operators - They need access everywhere
- Combine global + scoped roles - Base permissions + environment-specific extras
Troubleshooting
User Has No Access
Issue: User logs in but sees “No environments available.” Solutions:- Check user has at least one role assigned
- Verify role has environment access (global or scoped)
- Ensure environment exists and user has permissions
- Check role hasn’t been deleted
Permission Denied Errors
Issue: User gets 403 errors when performing actions. Solutions:- Check user’s roles have the required permission
- Verify permission applies to the correct environment
- Check role merging - user might have conflicting roles
- Review recent role changes
LDAP/OIDC Roles Not Syncing
Issue: User’s roles don’t update after group changes. Solutions:- User must log out and back in (roles sync on login)
- Verify IdP is sending updated group claims
- Check role mapping configuration
- Ensure roleId in mapping still exists
Source Code Reference
src/lib/server/authorize.ts- Authorization servicesrc/lib/server/auth.ts:272-431- Permission checkingsrc/lib/server/db/schema/pg-schema.ts:251-270- Database schemasrc/routes/api/roles/+server.ts- Role CRUDsrc/routes/api/users/[id]/roles/+server.ts- User role assignment
Next Steps
LDAP
Map Active Directory groups to roles
OIDC/SSO
Map IdP groups to roles
Local Users
Manually assign roles to users
Authentication
Back to authentication overview
