- JSON 70%
- JavaScript 13.7%
- PHP 11%
- Markdown 2%
- Yaml 1.4%
- Shell 1%
- XML 0.4%
- LESS 0.3%
- SQL 0.1%
OIDC Login for Flarum
An enterprise-grade OpenID Connect (OIDC) authentication extension for Flarum.
This extension allows users to log in or register using any standard OIDC provider (Google, Keycloak, Auth0, Azure AD, GitLab, etc.). It features robust auto-discovery, custom attribute mapping, and fully customizable login buttons.
Features
- Universal OIDC Support: Works with any provider compliant with the OpenID Connect 1.0 standard.
- Auto-Discovery: Automatically fetches endpoints and keys (JWKS) from the provider's discovery URL (
/.well-known/openid-configuration), with local caching for performance. - High Security:
- Supports
RS256,HS256,ES256signing algorithms. - New: Support for high-security
RS512andHS512algorithms. - Validates ID Tokens strictly: signature, issuer, audience/
azp, expiry andnonce. - Authorization Code flow with
state,nonceand PKCE (S256). - UserInfo is only used to fill gaps and must describe the same
subas the ID Token. - Only emails the provider marks
email_verifiedare trusted (see below).
- Supports
- Customizable UI:
- Edit button text, background colors, and text colors directly from the Admin panel.
- Use FontAwesome icons (e.g.,
fab fa-google) or custom image URLs for button icons.
- Attribute Mapping: Map custom provider claims (e.g.,
given_name,upn,oid) to Flarum's username, email, and avatar fields. - Stable user IDs: Accounts are linked by the ID Token's
subclaim.
Compatibility
| Flarum | Extension version | Branch | Login flow |
|---|---|---|---|
| 2.x | ^2.0 | master | Full-page redirect; the user returns to the page they started from |
| 1.8.x | ^1.21 | v1 | Popup window |
Composer picks the right version for your Flarum install automatically.
Installation
Install the extension via Composer:
composer require floxum/flarum-ext-oidc
Configuration
- Enable: Go to your Flarum Admin Panel -> Extensions and enable "OIDC Login".
- Settings: Click the settings icon (three dots) on the extension.
- Add Provider:
- Unique ID: A unique lowercase key (e.g.,
google,keycloak). - Discovery URL: The base URL of your Identity Provider (e.g.,
https://accounts.google.com). Do not include/.well-known/.... - Client ID & Secret: Obtain these from your provider.
- Unique ID: A unique lowercase key (e.g.,
- Styling:
- Use the color pickers to match your brand.
- Paste a FontAwesome class or an image URL for the icon.
- Mapping (Optional):
- If your provider uses non-standard keys (e.g., Azure AD uses
upninstead ofemail), enter them in the Attribute Mapping section.
- If your provider uses non-standard keys (e.g., Azure AD uses
The callback URL shown for each provider (https://your-forum/auth/oidc?provider={id}) must be registered with
the identity provider. It is always built from Flarum's configured url, not from the request's Host header.
Email trust
Flarum logs a trusted email straight into any existing account with the same address. To prevent account
takeover through an identity provider that allows unverified addresses, the email is only trusted when the
ID Token (or UserInfo) contains email_verified: true. Otherwise it is only suggested on the sign-up form and
Flarum asks the user to confirm it.
Some providers (e.g. Azure AD / Entra ID) never send email_verified. For those, tick
Trust email when the provider sends no email_verified claim if you are sure the provider only issues
verified addresses.
Provider Examples
| Provider | Discovery URL (Issuer) | Scopes |
|---|---|---|
https://accounts.google.com | openid profile email | |
| Keycloak | https://{server}/realms/{realm} | openid profile email |
| Auth0 | https://{tenant}.auth0.com/ | openid profile email |
| GitLab | https://gitlab.com | openid profile email |
| Azure AD | https://login.microsoftonline.com/{tenant}/v2.0 | openid profile email |
Troubleshooting
"White Screen" after Login
This typically occurs if Flarum cannot determine the User ID or if the popup window cannot communicate with the parent window.
- Solution: Check
storage/logs/flarum.logfor "OIDC Login Failed". The log will show the raw claims received from the provider, allowing you to see which field contains the ID (e.g.,oidvssub).
"Required options not defined: publicKey"
This extension automatically fetches the Public Key from your provider's JWKS endpoint.
- Solution: Ensure your server allows outbound connections to the provider's
jwks_uri. The extension caches these keys to prevent repeated requests.
SSL/Network Errors
If you are testing locally or using self-signed certificates, the extension may fail to connect.
- Solution: Ensure your server allows outbound HTTPS requests. In
src/AuthController.php, the Guzzle client is configured to be robust, but ensure your server's CA certificates are up to date.
Development & testing
docker-compose.yml starts Keycloak plus a Flarum 1 and a Flarum 2 forum with this extension linked in:
git worktree add .worktrees/v1 v1 # Flarum 1 needs the v1 branch build
docker compose up -d --build
| Service | URL | Login |
|---|---|---|
| Keycloak | http://localhost:18080 | admin / admin; realm flarum, users alice / alice-password and mallory / mallory-password (unverified email) |
| Flarum 1 | http://localhost:18081 | admin / admin-password |
| Flarum 2 | http://localhost:18082 | admin / admin-password |
The Keycloak client is flarum / flarum-client-secret, issuer http://localhost:18080/realms/flarum.
Playwright tests cover configuring a provider in the admin UI, sign-up, returning login and the security checks:
cd tests/e2e
npm install
npx playwright install chromium
npm test # or: npm run test:v1 / npm run test:v2
License
MIT
Credits
This extension is developed and maintained by Floxum and Mamluk.