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
- New account registration is rejected server-side, including account creation through OAuth; the registration page is hidden too. Internal startup provisioning can create the configured admin account.
Both variables must be set. This does not revoke existing accounts or sessions, or restrict API access to an admin role: authenticated users can access Manager resources. Without a preconfigured admin, registration remains enabled. Use Manager for trusted personal deployments, not as a multi-user isolation boundary.
Password Reset
If you forget your password:
- Set environment variables:
ADMIN_EMAIL=your@email.com
ADMIN_PASSWORD=new-password
ADMIN_PASSWORD_RESET=true
- Recreate the container so it picks up the new environment variables:
docker compose up -d --force-recreate app
-
Log in with new password
-
Remove
ADMIN_PASSWORD_RESET=truefrom environment and recreate again:
docker compose up -d --force-recreate app
Session Security
AUTH_SECRET
Signs session cookies and encrypts stored credentials, so changing it signs every user out. In Docker it is generated on first start and kept in the data volume (/app/data/.auth-secret) when unset. Outside Docker it is required for production.
Generate:
openssl rand -base64 32
Configure:
AUTH_SECRET=your-generated-secret
Session Duration
Sessions last 7 days and slide: once a session is more than a day old, the next request extends it by another 7 days, so an active session does not expire. A new session is created on each login.
Secure Cookies
Outside Docker, secure cookies default to true when NODE_ENV=production and false otherwise. The default docker-compose.yml forwards AUTH_SECURE_COOKIES=${AUTH_SECURE_COOKIES:-false}, so a Compose deployment defaults to non-secure cookies even though Compose sets NODE_ENV=production. Set it explicitly:
# HTTPS
AUTH_SECURE_COOKIES=true
# For HTTP on trusted networks only
AUTH_SECURE_COOKIES=false
Remote Access
Local Network (HTTP)
For accessing via IP on a local network:
# Include every URL you open the Manager from
AUTH_TRUSTED_ORIGINS=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=true
Cloudflare Tunnel
To reach a Manager on your local network through a Cloudflare Tunnel, including the Preview panel, follow Cloudflare Tunnel.
Passkeys
Passwordless authentication using WebAuthn.
Setup
Configure your domain:
# Docker or a production build on this machine
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://localhost:5003
# Local development with pnpm dev (the page is served by Vite)
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://localhost:5173
# Production
PASSKEY_RP_ID=yourdomain.com
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=https://yourdomain.com
Adding a Passkey
- Log in with password
- Go to Settings > Account
- Optionally enter a passkey name
- Click Add Passkey
- Follow browser/device prompts
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)
Mobile App
The mobile app at apps/mobile signs in with email/password, OAuth and passkeys against the same server.
QR pairing
Pairing connects the app to a Manager without typing the URL or signing in by hand.
- In the Manager, open Settings → Account → Connect a device, choose Show QR code, and select the Mobile app tab.
- Scan the code with the phone camera to open the app, or copy the
ocm://linkURL and use Scan pairing QR code or Paste pairing link on the app's Connect screen, or in Settings → Account → Switch Server. - Confirm the server on the app's pair screen. Pairing replaces the server the app is connected to, signs the old session out, and lists the phone as a paired device on the new server.
The same dialog's Browser / PWA tab carries a second code for signing a browser in: scan it with a phone camera and the phone opens the Manager's /pair page, which redeems the code and signs that browser in, so neither the URL nor a password has to be typed. It also works for an installed home-screen app, except that on iPhone the home-screen app starts from Sign in with QR code on its own sign-in screen. The browser code is single use and expires with the mobile one.
Codes expire after 3 minutes and work once. A code that expired, was already used, or came from a Manager with a different link version shows the reason on the pair screen or in an alert, and the app keeps its current server.
OAuth
The app completes OAuth through the @better-auth/expo contract, so the Manager must load the Better Auth expo() plugin and trust the ocmgrmobile:// origin in AUTH_TRUSTED_ORIGINS. AUTH_TRUSTED_ORIGINS still needs the server URLs described above, because the first entry is the auth base URL.
How each misconfiguration fails:
- When
ocmgrmobile://is not trusted, starting sign-in fails with the server's "Invalid callbackURL" error - When the
expo()plugin is missing, the browser sheet shows an error page from the Manager because there is noexpo-authorization-proxyroute, and closing it returns to sign-in without an error - The "did not return a session" message appears when the redirect reaches the app without a session cookie
The server URL entered in the app must use the same host as the Manager's auth base URL (the first AUTH_TRUSTED_ORIGINS entry), because the OAuth state cookie is set on the host the app connects to while the provider callback returns to the auth base URL.
Passkeys
Passkey sign-in is compiled in only with OCM_PASSKEY_DOMAIN=<domain> at build time. The value may be a bare host, a host with a port or a full URL; the config keeps only the hostname and fails the build when it cannot parse it. That domain must equal PASSKEY_RP_ID, PASSKEY_ORIGIN must be https://<domain>, and the domain must serve /.well-known/apple-app-site-association with a webcredentials entry for <TeamID>.dev.chriswritescode.ocmgrmobile. For EAS cloud builds, set OCM_PASSKEY_DOMAIN in the build profile env in eas.json or as an EAS environment variable, because the config is evaluated on the build worker.
Passkeys are iOS-only for now: the button is hidden on Android because the build writes only the iOS webcredentials entitlement and the Manager accepts a single PASSKEY_ORIGIN, so it cannot verify Android's APK-hash origin. Without the variable the passkey button is hidden, which is the default for LAN deployments.
Troubleshooting
Can't Log In
- Clear browser cookies
- Check credentials are correct
- Verify AUTH_SECRET hasn't changed
- Check AUTH_TRUSTED_ORIGINS includes the exact URL in your address bar.
localhostand127.0.0.1are different origins, and the default Docker Compose setup trusts onlyhttp://localhost:5003
Session Keeps Expiring
- Check AUTH_SECRET is persistent across restarts
- Verify cookies aren't being blocked
- Check AUTH_SECURE_COOKIES setting
Passkey Not Working
- Verify PASSKEY_RP_ID matches domain
- Check PASSKEY_ORIGIN is exact
- Try a different browser
- Ensure WebAuthn is supported