Conversation
|
@amauryconstant Thanks so much for the PR! <160 lines is 🔥 We will review and get merged very soon. Meanwhile, it would be great if you could update the documentation to include instructions on how to setup Authelia here: https://github.com/phasehq/docs/blob/main/src/pages/access-control/authentication/oidc-sso.mdx |
|
I'll create a MR for the docs as well. In the meantime, would you like me to provide specifics docker compose files, conf and anything else I used for testing so you can check yourselves? |
I think your PR instructions are good enough. Thanks! |
Override complete_login to check request.data for id_token when it's not available in the token object. This fixes authentication failures where dj-rest-auth's parse_token() only extracts access_token and refresh_token, causing the adapter to fall back to userinfo endpoint which returns 401.
|
While testing to build good docs, I noticed an issue with the token extraction. |
🔍 Overview
Phase currently supports several SSO/OIDC providers but lacks a lightweight, self-hosted option.
Authelia is an OpenID Certified™ authentication server that runs as a single Go binary (~25MB RAM), making it a natural complement to Authentik for self-hosters with smaller footprints or simpler identity needs. This PR adds Authelia as a named OIDC provider following the exact pattern established when Authentik was added in v2.50.2.
💡 Proposed Changes
Adds Authelia as a community-tier SSO provider. No new dependencies, no architectural changes — this reuses the existing
GenericOpenIDConnectAdapterandGenericOpenIDConnectProviderbase classes.Backend (Django / django-allauth):
api/authentication/providers/authelia/package (3 files) — thin adapter subclassingGenericOpenIDConnectAdapterwith Authelia's OIDC endpoint pathsAutheliaLoginViewinapi/views/auth.pyauthelia/inapi/urls.pyautheliaentry inSOCIALACCOUNT_PROVIDERSinsettings.pyFrontend (Next.js / NextAuth):
[...nextauth].tsusingtype: 'oidc'with Authelia's issuer URL'authelia'to the OIDC group in the JWT callback forid_tokenextractionAutheliaLogoSVG component + logo index exportSignInButtons.tsxEnvironment variables (all optional — provider activates only when set):
AUTHELIA_URLhttps://auth.example.com)AUTHELIA_CLIENT_IDAUTHELIA_CLIENT_SECRETSSO_PROVIDERSautheliato show the sign-in buttonFiles changed: 10 (3 new, 7 modified), ~106 insertions.
🖼️ Screenshots or Demo
None
📝 Release Notes
AUTHELIA_URL,AUTHELIA_CLIENT_ID,AUTHELIA_CLIENT_SECRET, and addingautheliatoSSO_PROVIDERS.❓ Open Questions
🧪 Testing
Manual testing performed:
response_types: ['code'],grant_types: ['authorization_code'], scopesopenid email profileid_tokenclaims (sub, email, name) propagate correctly through the JWT callbackTesting gaps:
🎯 Reviewer Focus
Start with these files in order:
backend/api/authentication/providers/authelia/views.py— Core adapter. Compare againstproviders/authentik/views.pyto verify the pattern is followed correctly. Key difference: Authelia's OIDC discovery URL is at issuer root (/.well-known/openid-configuration) rather than Authentik's/application/o/{slug}/path.frontend/pages/api/auth/[...nextauth].ts— Usestype: 'oidc'(generic OIDC) instead of a named NextAuth provider. Verify the provider block and JWT callback addition.backend/backend/settings.py— Confirm theSOCIALACCOUNT_PROVIDERSentry matches the existing pattern.Everything else is mechanical wiring (imports, routes, button entry, logo).
➕ Additional Context
GenericOpenIDConnectAdapterhandles OIDC discovery, JWKS validation, and userinfo fallback — the Authelia adapter is a thin wrapper that only provides URL construction.openid-clientlibrary and Authelia both default toclient_secret_basicfor token endpoint auth, so no explicittoken_endpoint_auth_methodconfiguration is needed.✨ How to Test the Changes Locally
Run an Authelia instance (Docker is easiest):
Configure an OIDC client in Authelia's
configuration.yml:Set environment variables in Phase:
Start Phase locally and verify the Authelia button appears on the sign-in page. Click through the full OAuth flow.
💚 Did You...