4.1 KiB
Authentication
OpenCode Manager uses single-user authentication designed for personal deployments.
Overview
The authentication system supports:
- Email/password login
- Passkey/WebAuthn authentication
- OAuth social login (optional)
- Session-based auth with secure cookies
First-Run Setup
On first launch with no admin account:
- You're redirected to the Setup page
- Create your admin account
- Optionally configure providers
- Start using the application
Pre-Configured Admin
Skip interactive setup for automated deployments:
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your-secure-password
When set:
- Admin user is created automatically
- Setup wizard is skipped
- Registration is disabled
Password Reset
If you forget your password:
- Set environment variables:
ADMIN_EMAIL=your@email.com
ADMIN_PASSWORD=new-password
ADMIN_PASSWORD_RESET=true
- Restart the application:
docker-compose restart
-
Log in with new password
-
Remove
ADMIN_PASSWORD_RESET=truefrom environment
!!! warning Remove the reset flag after successful reset to prevent accidental password changes.
Session Security
AUTH_SECRET
Required for production. Encrypts session data.
Generate:
openssl rand -base64 32
Configure:
AUTH_SECRET=your-generated-secret
Session Duration
Sessions expire after 7 days. A new session is created on each login.
Secure Cookies
By default, cookies require HTTPS in production:
# For HTTP on trusted networks only
AUTH_SECURE_COOKIES=false
Remote Access
Local Network (HTTP)
For accessing via IP on a local network:
# Include all access URLs (both frontend and backend)
AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003,http://192.168.1.244:5003
# Disable secure cookies for HTTP
AUTH_SECURE_COOKIES=false
Production (HTTPS)
For production with HTTPS:
AUTH_TRUSTED_ORIGINS=https://yourdomain.com
# AUTH_SECURE_COOKIES defaults to true
Passkeys
Passwordless authentication using WebAuthn.
Setup
Configure your domain:
# Local development (use backend port)
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://localhost:5003
# Production
PASSKEY_RP_ID=yourdomain.com
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=https://yourdomain.com
# Local network access
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://192.168.1.244:5003
!!! note "Port Selection" - Use the backend port (5003) for PASSKEY_ORIGIN - Not the frontend port (5173) - The origin must match where the auth API is served
Adding a Passkey
- Log in with password
- Go to Settings > Account
- Click Add Passkey
- Follow browser/device prompts
- Name your passkey
Supported Authenticators
- Touch ID / Face ID (macOS, iOS)
- Windows Hello
- Hardware security keys (YubiKey, etc.)
- Android fingerprint/face
Passkey Requirements
- RP ID must match the domain
- Origin must match exactly (including port)
- HTTPS recommended (required for some browsers)
Troubleshooting
Can't Log In
- Clear browser cookies
- Check credentials are correct
- Verify AUTH_SECRET hasn't changed
- Check AUTH_TRUSTED_ORIGINS includes your URL
Session Keeps Expiring
- Check AUTH_SECRET is persistent across restarts
- Verify cookies aren't being blocked
- Check AUTH_SECURE_COOKIES setting
- If accessing from a different site (cross-site, not just cross-origin), note that CORS alone is not sufficient: the auth config in
backend/src/auth/index.tssets nosameSiteoverride, so better-auth'sSameSite=Laxdefault prevents the session cookie from being attached to cross-site requests regardless ofcredentials: 'include'on the client. The app is designed same-origin (VITE_API_URLdefaults to''); cross-site access requires changingsameSiteto'none'withsecure: true, which is an open question rather than a supported configuration.
Passkey Not Working
- Verify PASSKEY_RP_ID matches domain
- Check PASSKEY_ORIGIN is exact
- Try a different browser
- Ensure WebAuthn is supported