Single Sign-On (OIDC)
TREK supports login via any OpenID Connect (OIDC) provider — Google, Apple, Authentik, Keycloak, and more.
Setup
- Register TREK as an OAuth/OIDC client at your provider
- Set the Redirect URI to:
https://your-trek-domain.com/api/auth/oidc/callback - In TREK: Admin Panel → Settings → Single Sign-On (OIDC)
- Enter: Display Name, Issuer URL, Client ID, Client Secret
- Save — the "Sign in with [Name]" button appears on the login page
Provider Examples
- Go to Google Cloud Console → Credentials
- Create OAuth Client ID → Web application
- Add redirect URI:
https://your-domain.com/api/auth/oidc/callback - In TREK:
- Display Name:
Google - Issuer URL:
https://accounts.google.com - Client ID + Secret from Google
- Display Name:
Authentik
- Create an OAuth2/OIDC Provider in Authentik
- Set redirect URI to
https://your-domain.com/api/auth/oidc/callback - In TREK:
- Display Name:
Authentik - Issuer URL:
https://your-authentik.com/application/o/trek/ - Client ID + Secret from Authentik
- Display Name:
Keycloak
- Create a Client in your Keycloak realm
- Set redirect URI
- In TREK:
- Display Name:
Keycloak - Issuer URL:
https://your-keycloak.com/realms/your-realm - Client ID + Secret from Keycloak
- Display Name:
How it Works
- User clicks "Sign in with [Provider]" on the login page
- Redirected to the provider for authentication
- After login, redirected back to TREK with an authorization code
- TREK exchanges the code for user info (email, name)
- If a user with that email exists → linked and logged in
- If no user exists and registration is allowed → new account created
- First user via OIDC becomes admin
Account Linking
- If you register with email/password first, then login via OIDC with the same email → accounts are automatically linked
- Once linked, you can use both methods to log in
- A "SSO" badge appears in your Settings showing the linked provider
OIDC-Only Mode
To disable password-based authentication entirely and require all users to log in via OIDC:
environment:
OIDC_ONLY: "true"
When enabled:
- The username/password login form is hidden
- Users can only authenticate via the configured OIDC provider
- Existing password-based accounts can still be accessed if they link their OIDC identity
- On a fresh install, there is no local admin account prompt — only OIDC login
This is useful for organizations that want to enforce SSO for all users.
Admin Role Mapping
Automatically assign or revoke admin roles based on OIDC claims:
environment:
OIDC_ADMIN_CLAIM: groups # The claim to check (default: "groups")
OIDC_ADMIN_VALUE: trek-admins # The value that grants admin
On every OIDC login, TREK checks the user's token. If the specified claim contains the specified value, the user is promoted to admin. If the value is absent, admin is revoked. This allows centralized role management through your identity provider (e.g. Authentik groups, Keycloak roles).
Invite Tokens + OIDC
Invite tokens are passed through the OIDC flow. If a user clicks an invite link and logs in via OIDC, the invite is consumed correctly and the user is registered even when public registration is disabled.
Two-Factor Authentication (2FA)
TREK supports TOTP-based two-factor authentication for an extra layer of security on password-based accounts.
Setup
- Go to Settings → Security
- Click Enable 2FA
- Scan the QR code with a TOTP-compatible authenticator app (e.g. Google Authenticator, Authy, 1Password)
- Enter the 6-digit code to confirm setup
- Save the backup codes in a safe place
Once enabled, you will be prompted for a TOTP code after entering your password on each login. 2FA can be disabled in Settings with your current password and a valid code.
Security Notes
- Login is rate-limited to 10 attempts per 15 minutes
- OIDC uses the authorization code flow (not implicit)
- OIDC users can set a password in Settings to also use password login
- Registration rules still apply — if registration is disabled, only existing users or invite link holders can login via OIDC