OIDC Authentication
Dawarich supports OpenID Connect (OIDC) authentication for self-hosted instances, allowing you to integrate with identity providers like Authentik, Authelia, Keycloak, and others.
Overviewβ
OpenID Connect (OIDC) is an identity layer built on top of OAuth 2.0. It allows users to authenticate using their existing identity provider credentials instead of creating a separate account in Dawarich.
OIDC authentication is only available for self-hosted Dawarich instances. Cloud-hosted instances use different authentication methods.
Prerequisitesβ
Before configuring OIDC, you'll need:
- A self-hosted Dawarich instance
- An OIDC-compatible identity provider (Authentik, Authelia, Keycloak, Azure AD, etc.)
- Administrator access to create an application/client in your identity provider
Environment Variablesβ
Configure the following environment variables in your docker-compose.yml file for both dawarich_app and dawarich_sidekiq services:
Required Variablesβ
| Variable | Description |
|---|---|
OIDC_CLIENT_ID | The client ID from your identity provider |
OIDC_CLIENT_SECRET | The client secret from your identity provider |
OIDC_ISSUER | The issuer URL of your identity provider (enables auto-discovery) |
OIDC_REDIRECT_URI | The callback URL: https://your-dawarich-domain/users/auth/openid_connect/callback |
Optional Variablesβ
| Variable | Default | Description |
|---|---|---|
OIDC_PROVIDER_NAME | Openid Connect | Custom display name for the login button |
OIDC_AUTO_REGISTER | true | Automatically create accounts for new OIDC users |
ALLOW_EMAIL_PASSWORD_REGISTRATION | false | Allow traditional email/password registration and signing in alongside OIDC |
Manual Endpoint Configuration (Alternative to Discovery)β
If your identity provider doesn't support OIDC discovery, you can configure endpoints manually:
| Variable | Description |
|---|---|
OIDC_HOST | The hostname of your identity provider |
OIDC_SCHEME | Protocol (https or http, default: https) |
OIDC_PORT | Port number (default: 443) |
OIDC_AUTHORIZATION_ENDPOINT | Authorization endpoint path (default: /authorize) |
OIDC_TOKEN_ENDPOINT | Token endpoint path (default: /token) |
OIDC_USERINFO_ENDPOINT | User info endpoint path (default: /userinfo) |
Configuration Exampleβ
Here's an example configuration in your docker-compose.yml:
services:
dawarich_app:
image: freikin/dawarich:latest
environment:
# ... other environment variables ...
OIDC_CLIENT_ID: your-client-id
OIDC_CLIENT_SECRET: your-client-secret
OIDC_ISSUER: https://auth.yourdomain.com
OIDC_REDIRECT_URI: https://dawarich.yourdomain.com/users/auth/openid_connect/callback
OIDC_PROVIDER_NAME: "Sign in with Authentik"
OIDC_AUTO_REGISTER: "true"
ALLOW_EMAIL_PASSWORD_REGISTRATION: "false"
# ... rest of configuration ...
dawarich_sidekiq:
image: freikin/dawarich:latest
environment:
# Same OIDC environment variables
OIDC_CLIENT_ID: your-client-id
OIDC_CLIENT_SECRET: your-client-secret
OIDC_ISSUER: https://auth.yourdomain.com
OIDC_REDIRECT_URI: https://dawarich.yourdomain.com/users/auth/openid_connect/callback
OIDC_PROVIDER_NAME: "Sign in with Authentik"
OIDC_AUTO_REGISTER: "true"
ALLOW_EMAIL_PASSWORD_REGISTRATION: "false"
# ... rest of configuration ...
Provider Setup Examplesβ
Authentikβ
- Log in to your Authentik admin interface
- Go to Applications β Providers β Create
- Select OAuth2/OpenID Provider
- Configure the provider:
- Name: Dawarich
- Authorization flow: Select an appropriate flow
- Client type: Confidential
- Redirect URIs:
https://dawarich.yourdomain.com/users/auth/openid_connect/callback
- Save and note the Client ID and Client Secret
- Go to Applications β Applications β Create
- Link the provider to the application
- Your issuer URL is typically:
https://authentik.yourdomain.com/application/o/dawarich/
Keycloakβ
- Log in to your Keycloak admin console
- Select your realm (or create a new one)
- Go to Clients β Create client
- Configure:
- Client type: OpenID Connect
- Client ID:
dawarich
- On the next screen:
- Client authentication: On
- Valid redirect URIs:
https://dawarich.yourdomain.com/users/auth/openid_connect/callback
- Save and go to the Credentials tab to get the Client Secret
- Your issuer URL is:
https://keycloak.yourdomain.com/realms/your-realm
Autheliaβ
- Add a client configuration to your Authelia configuration:
identity_providers:
oidc:
clients:
- id: dawarich
description: Dawarich Location History
secret: 'your-secret-hash'
public: false
authorization_policy: two_factor
redirect_uris:
- https://dawarich.yourdomain.com/users/auth/openid_connect/callback
scopes:
- openid
- email
- profile
- Your issuer URL is typically:
https://auth.yourdomain.com
Azure AD / Entra IDβ
- Go to Azure Portal β Azure Active Directory β App registrations
- Click New registration
- Configure:
- Name: Dawarich
- Redirect URI:
https://dawarich.yourdomain.com/users/auth/openid_connect/callback
- After creation, go to Certificates & secrets β New client secret
- Note the Application (client) ID and the secret value
- Your issuer URL is:
https://login.microsoftonline.com/your-tenant-id/v2.0
Testing the Integrationβ
-
Restart your Dawarich containers after updating environment variables:
docker compose down && docker compose up -d -
Navigate to your Dawarich login page
-
You should see a button with your custom provider name (or "Sign in with Openid Connect")
-
Click the button to be redirected to your identity provider
-
After authentication, you'll be redirected back to Dawarich
User Registration Behaviorβ
Auto-Registration Enabled (OIDC_AUTO_REGISTER=true)β
When a user authenticates via OIDC for the first time:
- A new Dawarich account is automatically created
- The email address from the OIDC provider is used
- The user is logged in immediately
Auto-Registration Disabled (OIDC_AUTO_REGISTER=false)β
When a user authenticates via OIDC:
- They must have an existing Dawarich account with the same email
- No new accounts are created automatically
- Users without existing accounts will see an error
Disabling Email/Password Registrationβ
To use OIDC as the only authentication method:
OIDC_AUTO_REGISTER: "true"
ALLOW_EMAIL_PASSWORD_REGISTRATION: "false"
This ensures all users must authenticate through your identity provider.
Troubleshootingβ
"Invalid credentials" after OIDC loginβ
- Verify the email from OIDC matches an existing account (if auto-registration is disabled)
- Check that
OIDC_AUTO_REGISTERis set totrueif you want automatic account creation
Redirect URI mismatchβ
- Ensure the
OIDC_REDIRECT_URIexactly matches what's configured in your identity provider - Check for trailing slashes
- Verify the protocol (http vs https)
Discovery failsβ
- Verify the
OIDC_ISSUERURL is accessible - Try appending
/.well-known/openid-configurationto the issuer URL in a browser - If discovery doesn't work, try manual endpoint configuration
OIDC button doesn't appearβ
- Check that both
OIDC_CLIENT_IDandOIDC_CLIENT_SECRETare set - Verify
SELF_HOSTED=true(default for self-hosted instances) - Check container logs for OIDC configuration messages
SSL/Certificate errorsβ
- Ensure your identity provider's SSL certificate is valid
- If using self-signed certificates, you may need to configure certificate trust
Security Considerationsβ
- Always use HTTPS for both Dawarich and your identity provider in production
- Keep your client secret secure and never commit it to version control
- Consider using two-factor authentication in your identity provider
- Regularly rotate client secrets according to your security policy