Skip to content

Configure OIDC / SSO login

Repod supports Single Sign-On via any standards-compliant OpenID Connect provider — Keycloak, Authentik, Zitadel, Azure AD (Entra ID), Okta, and ADFS have all been used with it. Once configured, users authenticate with your IdP and never enter a Repod-local password.

Repod implements the Authorization Code flow with PKCE (RFC 7636), the flow recommended for browser-based SPAs — there is no client secret exposed to the browser at any point; PKCE replaces it.


1. Prerequisites

  • Repod admin access to Administration → SSO / OIDC.
  • An OIDC application registered in your IdP, with:
  • A redirect URI pointing at https://<your-repod-host>/oidc-callback
  • A client ID and client secret
  • The openid email profile scopes enabled (default)
  • Your IdP's discovery URL — the standard /.well-known/openid-configuration document. Examples:
  • Keycloak: https://sso.example.com/realms/myorg/.well-known/openid-configuration
  • Azure AD: https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration
  • Okta: https://<org>.okta.com/.well-known/openid-configuration

Enterprise feature

OIDC is gated behind license_svc.check_feature("oidc") — it requires an Enterprise license (on-premise) or a plan that includes SSO (SaaS). On Community/unlicensed installations, GET /api/v1/auth/oidc/public-config always returns {"enabled": false} regardless of what is saved in settings.


2. Step 1 — Register the redirect URI in your IdP

Before touching Repod, create the OIDC client application in your IdP and set its allowed redirect URI to:

https://<your-repod-host>/oidc-callback

This is a fixed frontend route (OidcCallbackPage.js) — it is not configurable per-provider beyond the host itself. If Repod is reachable at more than one hostname, register each one as a separate allowed redirect URI in the IdP.


3. Step 2 — Open SSO settings in Repod

  1. Log in to Repod as an administrator.
  2. Navigate to Administration → SSO / OIDC.
  3. Turn on Activer le SSO OIDC. The rest of the form appears.

4. Step 3 — Configure the connection

Field Settings key Description
Libellé du bouton de connexion provider_name Label shown on the "Sign in with…" button on the login page. Default SSO.
Discovery URL discovery_url The IdP's /.well-known/openid-configuration URL. Repod fetches and caches this document for 5 minutes.
Client ID client_id From your IdP's OIDC application registration.
Client Secret client_secret From the same registration. Stored encrypted at rest (SETTINGS_ENCRYPTION_KEY).
Scopes scopes Space-separated OAuth scopes requested. Default openid email profile.
Redirect URI redirect_uri Leave empty to auto-compute as <app_url>/oidc-callback. Only set explicitly if app_url doesn't match what you registered in the IdP.

Click Tester before saving — this calls POST /api/v1/auth/oidc/test-discovery with the discovery URL and reports back the resolved authorization_endpoint, token_endpoint, and jwks_uri, or a clear error if the discovery document couldn't be fetched.

curl -X POST https://repod.example.com/api/v1/auth/oidc/test-discovery \
  -H "Authorization: Bearer $ADMIN_JWT" \
  -H "Content-Type: application/json" \
  -d '{"discovery_url": "https://sso.example.com/realms/myorg/.well-known/openid-configuration"}'
{
  "ok": true,
  "issuer": "https://sso.example.com/realms/myorg",
  "auth_ep": "https://sso.example.com/realms/myorg/protocol/openid-connect/auth",
  "token_ep": "https://sso.example.com/realms/myorg/protocol/openid-connect/token",
  "jwks_uri": "https://sso.example.com/realms/myorg/protocol/openid-connect/certs"
}

5. Step 4 — Map claims and provisioning

Field Settings key Default
Auto-provisioning auto_provision true — creates a local Repod user on first successful SSO login
Rôle par défaut default_role reader — role assigned when no group/role mapping matches
Claim → Nom d'utilisateur claim_username preferred_username (falls back to sub if absent)
Claim → Email claim_email email
Claim → Nom complet claim_fullname name
Claim → Groupes / Rôles (optionnel) claim_role empty — the ID token claim carrying the user's IdP groups/roles (e.g. groups). Leave empty to always use default_role.
Mapping groupes → rôles repod role_map {} — maps an IdP group/role value to a Repod role, e.g. {"repod-admins": "admin", "repod-uploaders": "uploader"}

The role claim can be either a single string or a list (typical for a groups claim). Repod checks each value against role_map and assigns the highest role among the matches (see How the role is decided); if nothing matches, default_role applies.

A user provisioned via SSO gets auth_source="oidc" and a random, unusable local password — they can never log in with a Repod-local password, only via SSO.

If Auto-provisioning is off and an unknown user completes the SSO handshake, Repod rejects the login with 403 and a message telling them to contact an administrator — no account is silently created.


6. Step 5 — Save

Click Sauvegarder la configuration SSO. This sends a PATCH /api/v1/settings/ request with the oidc section:

curl -X PATCH https://repod.example.com/api/v1/settings/ \
  -H "Authorization: Bearer $ADMIN_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "oidc": {
      "enabled": true,
      "provider_name": "Corporate SSO",
      "discovery_url": "https://sso.example.com/realms/myorg/.well-known/openid-configuration",
      "client_id": "repod",
      "client_secret": "s3cr3t",
      "scopes": "openid email profile",
      "auto_provision": true,
      "default_role": "reader",
      "claim_username": "preferred_username",
      "claim_role": "groups",
      "role_map": {"repod-admins": "admin", "repod-uploaders": "uploader"}
    }
  }'

GET /api/v1/settings/ returns the current configuration with client_secret masked (••••••••) — re-saving without changing the secret is safe, since the masked placeholder is stripped from the update rather than overwriting the real stored value.


7. How the login flow works

  1. The Repod login page calls GET /api/v1/auth/oidc/public-config (no auth required). If SSO is enabled and licensed, it shows a "Sign in with <provider_name>" button.
  2. The frontend generates a PKCE code_verifier/code_challenge pair and a random state, then calls POST /api/v1/auth/oidc/authorize with the challenge and state. Repod returns the IdP's authorization URL.
  3. The browser is redirected to the IdP, the user authenticates there, and the IdP redirects back to /oidc-callback with a code.
  4. The frontend calls POST /api/v1/auth/oidc/callback with code, state, and code_verifier. Repod exchanges the code for an ID token against the IdP's token endpoint, validates its signature against the IdP's JWKS, extracts the claims, resolves (or provisions) the local user, and returns a normal Repod access_token.

From this point on, the SSO-issued JWT is identical to one issued by local or LDAP login — every API call uses the same Authorization: Bearer <token> header.


7b. What you must know before you turn it on

These behaviours were checked by running the whole flow against a real OpenID Connect provider (Dex) and the real backend code.

A SSO login only opens a SSO account

Repod looks the user name up in its own user table. A login is accepted only if that account was created for SSO (its source is oidc); a new user is created that way automatically when Auto-provisioning is on. If the IdP user name equals the name of a local (or LDAP) account, the login is refused with 403 and the message "Le compte '…' existe déjà et n'est pas un compte SSO", and the refusal is written to the audit log (OIDC_LOGIN, FAILURE).

Older versions did not check this: an IdP user named like a local admin account received a token for it, with its role, no password and no Repod MFA (tested against a real provider). If you used SSO that way, those accounts are now refused until you convert them (below).

  • Create an SSO account yourself (useful with Auto-provisioning off): Administration → Utilisateurs → Créer un utilisateur, type Compte SSO. There is no password. Through the API: POST /api/v1/auth/users with "auth_source": "oidc" and no password.
  • Convert an existing local account: edit it and tick Convertir en compte SSO (PATCH /api/v1/auth/users/{name} with "auth_source": "oidc"). The role is kept, the local password is invalidated, and the change is one-way (you cannot convert back; LDAP accounts and your own account cannot be converted).
  • The user name must still be exactly what the IdP sends in the claim you chose. Pick a claim that only the IdP administrators can set: preferred_username is user-editable in some providers (Keycloak when "Edit username" is on).

How the role is decided

  • With a group mapping (Claim → Groupes / Rôles and Mapping groupes → rôles repod filled in), the IdP is the authority: the role is recomputed at every login and updated in Repod if it changed (written to the audit log as USER_ROLE_CHANGE). A user who leaves the mapped groups falls back to the Rôle par défaut at the next login. A role edited by hand in Administration → Utilisateurs is overwritten by the next login.
  • Without a mapping, the role is chosen once (the default role at creation, or the one you set) and a login never changes it.
  • The highest role wins. A user in several mapped groups gets the most powerful of their roles (admin > maintainer > uploader > auditor > reader), whatever order the IdP sends the groups in. A custom role is only used when no built-in role matches.
  • A role that does not exist is refused when you save: role_map and the default role are checked (422), so a typo cannot make a login fail later.
  • The last administrator is never demoted. If the IdP would remove the admin role from the only active administrator, Repod keeps it and logs a warning, so the installation cannot end up without an administrator.

Changes apply at the next login

An open session keeps the role of its token (up to its expiry, 60 minutes by default). Group changes in the IdP take effect the next time the person signs in.

  • MFA is the IdP's job. An SSO login returns a Repod token directly: Repod's own TOTP and its account lockout are not applied. Enforce MFA in the IdP.
  • The token is validated (signature against the IdP's keys, iss, aud and expiry), and the flow uses PKCE S256. If the username claim is the e-mail address and the IdP states email_verified: false, the login is refused. An IdP that does not send email_verified (Azure AD) is accepted.

8. Verify it worked

  1. Open the Repod login page in an incognito/private window. Confirm the "Sign in with <provider_name>" button appears.
  2. Click it, authenticate against your IdP, and confirm you land back on the Repod dashboard.
  3. Check Administration → Utilisateurs (or GET /api/v1/auth/users, admin only) for the newly provisioned account — auth_source should read oidc.
  4. Check the audit log for an OIDC_PROVISION entry (first login only) followed by OIDC_LOGIN:
    curl -H "Authorization: Bearer $ADMIN_JWT" \
      "https://repod.example.com/api/v1/artifacts/audit/logs?action=OIDC_LOGIN&per_page=5"
    
  5. If the button doesn't appear, re-check enabled: true was actually saved (GET /api/v1/settings/) and that your license includes the oidc feature.

9. Troubleshooting

Login button never appears

  • GET /api/v1/auth/oidc/public-config returns {"enabled": false} if oidc.enabled is false in settings or the license doesn't include the oidc feature — the response doesn't distinguish the two, by design (avoids leaking licensing details on an unauthenticated endpoint).

401 on callback: "ID token invalide ou expiré"

  • The IdP's clock is out of sync with the Repod server, or the client_id used to validate the token's aud claim doesn't match what the IdP issued it for. Re-check the client ID field.

403 after successful IdP login: "Utilisateur inconnu"

  • auto_provision is off and no account exists for that username. Create an SSO account for that person first (section 7b), or enable auto-provisioning.

403 after successful IdP login: "Le compte … existe déjà et n'est pas un compte SSO"

  • An account with that name exists but is local or LDAP. Convert it to an SSO account (section 7b), or change the IdP claim so that the names no longer collide.

Discovery test fails with a network error

  • Confirm the backend container can reach the discovery URL: docker compose exec backend python3 -c "import urllib.request as u; print(u.urlopen('<discovery_url>', timeout=10).status)" (the image has no curl). A corporate IdP behind a VPN/firewall may not be reachable from the Repod host.