Repository navigation
Dashboard: single sign-on with authentik (OIDC), users matched by e-mail - #200
Merged
Merged
Conversation
The local dashboard can now sign users in through an OpenID Connect provider (authentik by default). The backend runs the Authorization Code flow with PKCE as a confidential client, validates the ID token against the provider's JWKS (issuer, audience, nonce, expiry), and issues the existing HttpOnly session cookie, so no provider token reaches the browser. - Users are mapped to existing dashboard accounts by e-mail (case-insensitive). Unknown or duplicated addresses are refused, and the role always comes from the local account. - email_verified is required by default (OIDC_REQUIRE_EMAIL_VERIFIED). - Sign-out of an SSO session continues to the provider's end-session endpoint (RP-initiated logout). - Admins can create SSO-only accounts (no password, e-mail required). - OIDC_DISABLE_PASSWORD_LOGIN=true makes the dashboard SSO-only. It only takes effect while SSO is fully configured, so it cannot lock everybody out. - Unique case-insensitive index on dashboard_users.email (init_db and migration 032). - Configured via OIDC_* env vars; documented in docs/sso-authentik.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BBzs29kfDyFwPxXT6WfTJH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds "Sign in with authentik" to the built-in dashboard (
/dashboard). Any standards-compliant OpenID Connect provider works the same way.server/oidc.py). It discovers the provider's endpoints and checks the ID token's signature against the provider's JWKS (RS/ES/PS, or HS with the client secret). It also checks issuer, audience, nonce and expiry, and refusesalg=none. It then issues the existing HttpOnly session cookie, so no provider token reaches the browser. There are no new dependencies (stdlib HTTP plus python-jose).dashboard_users.email. Unknown or ambiguous addresses are refused, and accounts are never auto-created. The role always comes from the local account.email_verified: required by default;OIDC_REQUIRE_EMAIL_VERIFIED=falserelaxes it. If the ID token has no e-mail, the userinfo endpoint is used instead, and itssubmust match the ID token's.end_session_endpoint(RP-initiated logout).OIDC_DISABLE_PASSWORD_LOGIN=truemakes the dashboard SSO-only. The password form and "Change password" are hidden, password logins are refused, and existing password sessions stop working. On a fresh install, the setup wizard creates a password-less admin and sends the browser through SSO. The setting only takes effect while SSO is fully configured, so it cannot lock everybody out.dashboard_users.emailis created ininit_dband by migration032. If duplicates already exist, the migration aborts with the list of addresses.init_dbinstead logs them and skips the index, so measurement ingestion keeps running, and SSO refuses those addresses until they are fixed.?sso_error=, the SSO-only setup wizard, "SSO only" tags in the users list, and an account card that is aware of SSO.OIDC_*env vars inconfig.py,.env.exampleanddocker-compose.yml. The newdocs/sso-authentik.mdcovers authentik setup, theemail_verifiedmapping and troubleshooting.Tests
test-data/test_oidc_sso.py(23 tests, added to CI). It uses a fake provider and an RSA key generated during the test, and covers the happy path, PKCE/state/nonce, bad tokens (audience, issuer, expiry, signature,alg=none, HS256),email_verifiedand its override, the userinfo fallback, unknown and ambiguous users, the password toggle, logout redirect, and SSO-only accounts.🤖 Generated with Claude Code
https://claude.ai/code/session_01BBzs29kfDyFwPxXT6WfTJH
Generated by Claude Code