Supported Providers
Dockhand works with any OIDC-compliant Identity Provider:- Keycloak - Open source IAM solution
- Authentik - Modern identity provider
- Auth0 - Cloud authentication service
- Okta - Enterprise identity platform
- Azure Active Directory - Microsoft cloud identity
- Google Workspace - Google’s identity platform
- GitLab - Built-in OIDC support
- Authelia - Self-hosted SSO portal
- Zitadel - Cloud-native identity platform
Configuration
1. Configure Your Identity Provider
Before configuring Dockhand, set up an OIDC client in your IdP: Client Type: ConfidentialGrant Type: Authorization Code
Redirect URI:
https://dockhand.example.com/api/auth/oidc/callbackPKCE: Required (S256) Save these values:
- Issuer URL (e.g.,
https://keycloak.example.com/realms/master) - Client ID (e.g.,
dockhand) - Client Secret (keep secure)
2. Add OIDC Provider in Dockhand
Navigate to Settings > Authentication > OIDC Providers and click Add Provider. Or via API:Configuration Fields
Display name for the provider (shown on login page)
Enable/disable this provider without deleting configuration
OIDC issuer URL (base URL for .well-known/openid-configuration)Examples:
- Keycloak:
https://keycloak.example.com/realms/master - Auth0:
https://tenant.auth0.com - Authentik:
https://auth.example.com/application/o/dockhand/
OAuth2 Client ID from your Identity Provider
OAuth2 Client Secret (stored encrypted in database)
Callback URL where IdP sends authorization code.
Must be
https://YOUR_DOMAIN/api/auth/oidc/callbackOAuth2 scopes to request (space-separated)
JWT claim containing the username
JWT claim containing the email address
JWT claim containing the display name
JWT claim for admin role detection (e.g.,
realm_roles, groups)Value(s) in adminClaim that grant admin access. Comma-separated for multiple.Examples:
- Single:
admin - Multiple:
admin,superuser,sysadmin
JWT claim containing group/role memberships (Enterprise)
Map IdP groups to Dockhand roles (Enterprise). JSON array of mappings.Example:
Testing Configuration
Test your OIDC setup before enabling:Authentication Flow
1. User Initiates Login
User clicks “Sign in with Keycloak” on the login page. Dockhand generates:- State: 32-byte random value (CSRF protection)
- Nonce: 16-byte random value (replay protection)
- PKCE Code Verifier: 32-byte random value
- PKCE Code Challenge: SHA-256 hash of verifier
2. User Authenticates with IdP
User logs in at the Identity Provider (username/password, 2FA, etc.).3. IdP Redirects Back
After successful authentication, IdP redirects to:4. Dockhand Exchanges Code for Tokens
Dockhand validates the state, then exchanges the authorization code:5. Extract User Claims
Dockhand decodes the ID token and optionally fetches userinfo:6. Create/Update Local User
Dockhand creates or updates the local user account:7. Assign Admin Role
IfadminClaim and adminValue are configured:
8. Create Session
Dockhand creates a session and sets the session cookie:9. Redirect to Dashboard
User is redirected to the dashboard (or original destination URL).Admin Role Mapping
Automatically grant admin access based on IdP claims:realm_roles: ["admin"] or realm_roles: ["superuser"], they receive the Admin role in Dockhand.
Multiple Admin Values
Use comma-separated values to accept multiple groups:Role Mappings (Enterprise)
Map IdP groups to Dockhand roles for fine-grained access control:1. Create Roles
First, create roles in Dockhand (Settings > Roles):- Docker Admins (ID: 2) - Full access
- Docker Viewers (ID: 3) - Read-only access
- Dev Team (ID: 4) - Access to dev environment only
2. Configure Role Mappings
Update OIDC provider with role mappings:3. Configure IdP to Send Groups
Ensure your IdP includes group memberships in the ID token or userinfo response: Keycloak: Add a mapper to include group memberships in thegroups claim.
Auth0: Create a rule to add groups to the ID token.
Azure AD: Include GroupMember.Read.All permission and map groups.
How It Works
When a user logs in:- Dockhand extracts the groups claim:
["dockhand-viewers", "dev-team"] - Matches claim values to role mappings
- Assigns Dockhand roles: Viewer (ID 3), Dev Team (ID 4)
- Removes roles no longer present in IdP groups
Provider-Specific Examples
Keycloak
Authentik
Auth0
https://dockhand.example.com/roles).
Azure Active Directory
SSO-Only Mode
Disable local username/password authentication:Security Features
PKCE (Proof Key for Code Exchange)
Dockhand uses PKCE (RFC 7636) to prevent authorization code interception attacks:- Generate 32-byte random
code_verifier - Compute
code_challenge = SHA256(code_verifier)in base64url - Send
code_challengewith authorization request - Send
code_verifierwith token exchange - IdP verifies
SHA256(code_verifier) === code_challenge
State Parameter (CSRF Protection)
Dockhand generates a cryptographically random state parameter:- 32 bytes of entropy (256 bits)
- Stored in-memory with 10-minute expiration
- Validated on callback
- Single-use (deleted after validation)
Nonce Parameter (Replay Protection)
Dockhand includes a nonce in the ID token:- 16 bytes of entropy (128 bits)
- Included in authorization request
- IdP echoes it in ID token
- Validated on callback
Troubleshooting
Invalid Redirect URI
Error:redirect_uri_mismatch
Solution: Ensure the redirect URI in Dockhand exactly matches the one configured in your IdP:
Discovery Document Not Found
Error:Failed to fetch OIDC discovery document
Solution: Verify the issuer URL is correct and accessible:
- Missing
/realms/{realm-name}in Keycloak URLs - Trailing slash in issuer URL
- Firewall blocking outbound HTTPS from Dockhand
User Creation Failed
Error:Username claim not found in token
Solution: Check the usernameClaim configuration. Decode your ID token at jwt.io and verify the claim name.
Admin Role Not Assigned
Issue: User logs in but doesn’t have admin access. Solution:- Verify
adminClaimandadminValueare configured - Check the ID token contains the admin claim
- Ensure claim value matches
adminValueexactly (case-sensitive) - Try comma-separated values if using multiple groups
Source Code Reference
src/lib/server/auth.ts:1128-1533- OIDC authentication logicsrc/routes/api/auth/oidc/+server.ts- CRUD endpointssrc/routes/api/auth/oidc/[id]/initiate/+server.ts- SSO initiationsrc/routes/api/auth/oidc/callback/+server.ts- Callback handlersrc/routes/api/auth/providers/+server.ts- Provider list
Next Steps
RBAC
Configure role-based access control (Enterprise)
Local Users
Manage fallback admin accounts
LDAP
Connect to Active Directory (Enterprise)
Two-Factor Auth
Add 2FA for local admin accounts
