Federated Login (SSO / OIDC)
Starting from v1.8.0, RAG-DocBot supports multi-provider OpenID Connect (OIDC) login with Authorization Code + PKCE (S256). Users can log in via your organisation's identity provider instead of (or in addition to) a local password.
For the full technical reference see AUTH.md in the RAG-DocBot source repository.
Supported Identity Providers
Pre-tested integrations are available for:
- Microsoft Entra ID (formerly Azure AD)
- Google Workspace
- Keycloak
- Any standards-compliant OIDC IdP
How It Works
- An admin configures a provider in the admin UI. The configuration is stored in the
oidc_providersPostgres table. - Users visit the login page and select their provider. The browser is redirected to the IdP for authentication.
- On successful login, RAG-DocBot exchanges the authorisation code for an ID token (PKCE S256 prevents code interception).
- If the user doesn't exist locally, they are provisioned automatically (JIT provisioning) with the role and groups derived from the IdP claims.
- Group membership from IdP claims is synced on first login. After provisioning, role and group management is handled within RAG-DocBot (not overwritten on every login).
Configuring a Provider
Via the Admin UI (recommended)
-
Log in as an admin and navigate to Settings → SSO Providers.
-
Click Add Provider and fill in the fields:
- Name — a short identifier (e.g.
entra,google) - Display name — shown on the login page button
- Client ID — from your IdP's app registration
- Client secret — stored encrypted at rest; never returned by the API
- Discovery URL — the IdP's
.well-known/openid-configurationendpoint - Redirect URI — must match what is registered with the IdP (e.g.
https://docbot.example.com/api/auth/oidc/entra/callback) - Scopes — space-separated (default:
openid email profile) - Admin groups — IdP group names whose members are auto-promoted to the
adminrole on first login
- Name — a short identifier (e.g.
-
Click Test to verify the provider configuration is reachable before saving.
Via Environment Variables (fallback / bootstrap)
Env-var configuration is used as a fallback when the oidc_providers table is empty. This is useful for scripted deployments or bootstrapping a fresh instance.
OIDC_PROVIDERS=entra,google
OIDC_ENTRA_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
OIDC_ENTRA_DISCOVERY_URL=https://login.microsoftonline.com/<TENANT_ID>/v2.0/.well-known/openid-configuration
OIDC_ENTRA_REDIRECT_URI=https://docbot.example.com/api/auth/oidc/entra/callback
OIDC_ENTRA_SCOPES=openid email profile
OIDC_ENTRA_ADMIN_GROUPS=DocBot-Admins
OIDC_GOOGLE_CLIENT_ID=<google-client-id>.apps.googleusercontent.com
OIDC_GOOGLE_DISCOVERY_URL=https://accounts.google.com/.well-known/openid-configuration
OIDC_GOOGLE_REDIRECT_URI=https://docbot.example.com/api/auth/oidc/google/callback
Client secrets must be supplied as Docker secrets, not as plain env vars:
echo "<entra-client-secret>" | docker secret create oidc_entra_client_secret -
echo "<google-client-secret>" | docker secret create oidc_google_client_secret -
Once a provider is saved via the admin UI, the oidc_providers table takes precedence and env-var config is ignored for that provider.
Admin API
| Endpoint | Description |
|---|---|
GET /api/admin/oidc/providers | List all configured providers |
POST /api/admin/oidc/providers | Create a new provider |
GET /api/admin/oidc/providers/{id} | Get provider details (client_secret is never returned; secret_set: bool indicates whether it's configured) |
PATCH /api/admin/oidc/providers/{id} | Update a provider |
DELETE /api/admin/oidc/providers/{id} | Delete a provider |
POST /api/admin/oidc/providers/{id}/test | Test the provider's discovery URL and connectivity |
User-Facing Endpoints
| Endpoint | Description |
|---|---|
GET /api/auth/oidc/providers | List providers visible on the login page |
GET /api/auth/oidc/{provider_id}/login | Initiate OIDC login (redirects to IdP) |
GET /api/auth/oidc/{provider_id}/callback | OIDC callback handler (handles IdP redirect) |
JIT Provisioning & Group Sync
- Users are created automatically on their first successful OIDC login.
- The user's
roleandgroupsare set from IdP claims on first login only. Subsequent logins do not overwrite role or group assignments managed within RAG-DocBot (see v1.8.0 changelog for the fix to issue #328). - Use
OIDC_<NAME>_ADMIN_GROUPS(env) or the Admin groups field in the UI to automatically promote members of specific IdP groups to theadminrole on provisioning.
Security Notes
- PKCE with S256 challenge method is always used — plain PKCE is not supported.
client_secretis encrypted at rest using theMFA_ENCRYPTION_KEY(Fernet). It is never returned by any API endpoint. Thesecret_set: boolfield indicates whether a secret has been configured.- OIDC-only users have a
NULLhashed_passwordin the database — they cannot log in via the username/password endpoint.