Overview
Dockhand supports flexible authentication that can be disabled for simple setups or enabled with multiple providers for enterprise security.Authentication is optional in Dockhand. When disabled, the API is fully accessible without credentials.
Authentication State
Always check the authentication state before making API calls:Check Session
Whether the current session is authenticated
Whether authentication is enabled globally
Authenticated user details (only when authenticated)
User ID
Username
Email address
Display name for UI
Whether user has admin privileges (Enterprise only)
Authentication provider:
local, ldap, or oidcRBAC permissions (Enterprise only)
Authentication Methods
Dockhand supports three authentication methods:Local Authentication (Free)
Database-backed username/password authentication:- Bcrypt password hashing
- Rate limiting (5 attempts per IP/username)
- Optional MFA (Enterprise)
LDAP Authentication (Enterprise)
Integrate with existing LDAP/Active Directory:- Multiple LDAP servers
- Automatic user provisioning
- Group-based role mapping
OIDC/SSO Authentication (Free)
Single Sign-On with OpenID Connect providers:- Support for any OIDC-compliant provider
- OAuth 2.0 authorization code flow
- Automatic user creation on first login
Login Flow
Local Login
Username
Password
Authentication provider:
local, ldap, or ldap:ID for specific LDAP config6-digit MFA code (if MFA is enabled for the user)
When MFA is required, submit the login request again with the
mfaToken parameter.LDAP Login
LDAP authentication automatically creates local users on first login. Enterprise license required.
OIDC/SSO Login
OIDC uses browser-based redirects. The flow is:- Initiate OIDC flow
- Redirect user to authorization URL
- Provider redirects back to callback
- Session cookie is set automatically
Session Management
Session Cookies
Dockhand uses HTTP-only session cookies:Using Sessions in Requests
Include the session cookie in all API requests:Session Duration
Sessions remain valid until:- User explicitly logs out
- Server restarts (sessions are stored in-memory)
- Session expires (configurable, default: 7 days)
Logout
Public Endpoints
These endpoints are accessible without authentication:/api/auth/login- Login/api/auth/logout- Logout/api/auth/session- Check session status/api/auth/settings- Get auth configuration/api/auth/providers- List available auth providers/api/auth/oidc/*- OIDC flow endpoints/api/license- License information/api/changelog- Application changelog/api/dependencies- Dependency versions/api/health- Health check/api/settings/theme- Theme settings/api/git/webhook/*- Git webhooks (validated by signature)
Initial Setup Mode
When authentication is enabled but no admin user exists:The
/api/users POST endpoint is publicly accessible only when no admin user exists. This allows initial setup.Authorization & Permissions
Free Edition
When authentication is enabled in Free edition:- All authenticated users have full access to all resources
- No role-based access control
- OIDC providers supported for SSO
Enterprise Edition
Enterprise edition adds:- RBAC (Role-Based Access Control)
- LDAP/Active Directory integration
- Multi-Factor Authentication (MFA)
- Environment-scoped permissions
- Audit logging
Permission Model
Permissions are organized by resource and action:Permission Checks
API endpoints check permissions before allowing operations: 403 Forbidden - Insufficient permissions:Security Best Practices
Password Requirements
- Minimum length: 8 characters
- Stored using bcrypt with cost factor 10
- No maximum length restriction
Rate Limiting
Login attempts are rate-limited per IP + username:- 5 failed attempts trigger rate limiting
- Exponential backoff: 5s, 15s, 30s, 60s, 60s
- Successful login clears the rate limit
Session Security
- HttpOnly cookies prevent XSS attacks
- SameSite=Lax prevents CSRF attacks
- Secure flag enabled when using HTTPS
- Sessions invalidated on logout
MFA (Enterprise)
Time-based One-Time Passwords (TOTP):- Compatible with Google Authenticator, Authy, etc.
- 6-digit codes
- 30-second time window
- Per-user enrollment
Environment Variables
Configure authentication behavior:Example: Full Authentication Flow
Troubleshooting
Common Issues
401 Unauthorized on every request- Ensure cookies are enabled and being sent
- Check that session cookie is valid
- Verify authentication is enabled
- Check user permissions in Enterprise edition
- Verify environment access for the target environment
- Ensure user has required role assigned
- Wait for the specified retry-after duration
- Check for multiple failed login attempts
- Verify correct username and password
- Test LDAP connection via
/api/auth/ldap/{id}/test - Verify LDAP credentials and configuration
- Check LDAP server is reachable
- Verify redirect URI is registered with provider
- Check OIDC configuration matches provider settings
- Test OIDC connection via
/api/auth/oidc/{id}/test
