Skip to main content

Single sign-on and 2FA

Version
since 2.x, describes 2.52.14
Feature flag
oidc_federation
For
Workspace user, Platform operator

The platform can sign users in through an identity provider you register (any OpenID Connect provider), creating or linking a platform account on the first login. Who may do what on the platform is still decided by the platform: an identity provider login never grants operator roles. For password sign-ins the platform applies its own second factor (a time-based code from an authenticator app, or a one-time code sent by e-mail); for identity-provider sign-ins the second factor is the provider's.

What it does​

  • Signs users in with the OpenID Connect authorization code flow with PKCE (S256). The provider is found through its discovery document; the ID token is validated against the provider's published signing keys, issuer, audience, nonce and expiry before any claim is read.
  • Reads four claims from the validated ID token: the subject (sub), the e-mail address, the e-mail-verified assertion and the display name. The default claim keys are email, email_verified and name; each can be replaced per provider with a claim mapping (a mapped key replaces the default, it does not fall back to it).
  • Matches the login to a platform account in a fixed order: an identity already linked to this provider and subject wins; otherwise a platform account whose own e-mail is verified and equals the verified e-mail claim is linked; otherwise, if the provider allows sign-up, an account is created; otherwise the login is refused.
  • Creates accounts just in time: the new account carries the e-mail address (marked verified), a first and last name split from the name claim (the part of the e-mail before @ when there is no name claim) and no password. Nothing else is copied: no workspace membership, no permissions, no operator role.
  • Applies two-factor authentication only to password sign-ins. Identity-provider sessions and social sign-in sessions skip the platform's second factor; the identity provider's own policy applies there.
  • Can attach a user to an Organizations entry on every identity-provider login when an ID token claim matches a rule the operator configured (see Organizations).
  • Shows one Continue with (provider name) button per enabled provider on the web app's login page. Several providers can be registered and enabled at the same time.

Where it is​

SurfacePath
Web app (sign-in)Login page: Continue with (provider name) below the password form; the browser returns to /auth/oidc/{provider_id}/callback in the app
Web app (2FA)Account, Two-Factor Authentication: Enable 2FA, Disable 2FA
Operator consolePlatform, then Identity providers; Platform, then Organizations, OIDC rules tab for auto-attach rules
API (public)GET /auth/oidc/providers, GET /auth/oidc/{provider_id}/authorize?redirect_uri=, GET /auth/oidc/{provider_id}/callback?code=&state=
API (password sign-in)POST /auth/login, then POST /auth/login/2fa (authenticator code) or POST /auth/login/token (e-mailed code)
API (2FA settings)GET /api/v1/settings/two-factor/enable (new secret), POST /api/v1/settings/two-factor/enable, POST /api/v1/settings/two-factor/disable, GET /api/v1/settings/two-factor/check
API (operators)GET, POST /admin/oidc/providers; PATCH, DELETE /admin/oidc/providers/{id}; POST /admin/oidc/providers/{id}/test; GET, POST /admin/organizations/{id}/oidc-rules; DELETE /admin/organizations/{id}/oidc-rules/{rule_id}
CLInone; the CLI signs in with a workspace access token, see CLI

How to use it​

Register an identity provider (operator)​

  1. Register the platform at your identity provider as a confidential client and keep the client secret. Place the secret in the API's environment under a name of your choice before the API starts; the platform stores only that name, never the value, and does not read environment changes while running.
  2. In the operator console open Platform, then Identity providers, and press Register provider. Fill in Name, Issuer URL (the discovery document must be served at <issuer>/.well-known/openid-configuration and the token issuer must equal the URL exactly), Client id, Client secret reference (the environment variable name from step 1), Scopes (default openid email profile), the Claim mapping for e-mail and name when your provider uses other claim names, and Allow signup. A new provider starts disabled.
  3. Register the callback address at your identity provider. It is the web app's origin followed by /auth/oidc/{provider_id}/callback, where the provider id is the one shown after step 2.
  4. Press Test discovery. Success means the discovery document and the signing keys were fetched and the client configuration is usable. A failure carries the reason (issuer unreachable, invalid discovery document, secret variable not set); it never carries a secret value.
  5. Switch the provider's Enabled toggle on.
  6. Switch on the oidc_federation feature flag under Platform, then Feature flags. The login page now shows the provider's button. The provider routes in steps 2 to 5 work with the flag off on purpose, so bring-up completes before anything is visible to users.

Sign in through your identity provider (user)​

  1. On the login page press Continue with (provider name). The browser goes to the identity provider.
  2. Sign in there. If the provider enforces a second factor, it does so now.
  3. The browser returns to the app, which shows Verification in Progress and then your workspace. On the first login the platform links your existing account (same verified e-mail) or creates one, if the provider allows sign-up. A refused login returns you to the login page with the reason (see Reasons a sign-in is refused under Numbers).

Attach users to an organisation by claim (operator)​

  1. Open Platform, then Organizations, select the organisation and open the OIDC rules tab. Press Add rule and give the provider, the Claim name, the Match value and a reason.
  2. On each identity-provider login the platform compares every top-level string claim of the ID token, plus the pseudo-claim email_domain (the domain of the verified e-mail, lower-cased), with the rules of that provider. Each match adds the user to the organisation as a member if they are not one yet. Membership is never removed by a rule.
  3. Rules are evaluated only while the organization_tier flag is on, and rules of a deleted organisation are ignored. A duplicate rule is refused with organization_oidc_rule_exists.

Two-factor authentication for password sign-ins (user)​

Every e-mail-and-password sign-in has a second step. A user with an authenticator app enrolled enters the 6-digit code from the app. A user without one receives a 6-digit one-time code by e-mail and enters that. Enrolment is on the Account page, Two-Factor Authentication: press Enable 2FA, scan the QR code (or type the secret key into the app as a time-based, six-digit entry), enter the current code and press Enable. Disabling asks for the current code. Step-by-step instructions for the released service are in Account and sign-in.

On-demand and on-prem​

  • On-demand (web): password sign-ins on the public portal use the second factor described above; the social sign-in options are listed in Account and sign-in. Sign-in through your organisation's identity provider is switched on: we register the provider, so write to [email protected] to have yours added.
  • Licensed on-prem: your operators register the identity provider, test discovery, enable it and then switch on oidc_federation; see Deployment and integration for the order and Configuration for the flag. Local accounts (e-mail and password with the second factor) keep working alongside the identity provider. Operator roles are granted through staff administration, never by the identity provider; see Administration.

Numbers​

WhatValueWhere it is set
Lifetime of a started sign-in attempt (the state value)10 minutes, single use; an expired, reused or unknown state answers 401 oidc_state_mismatchplatform
state and nonce32 bytes of randomness each; the nonce and the PKCE verifier never leave the platformplatform
PKCE methodS256platform
Default scopes requestedopenid email profileper provider
ID-token age checkoff by default; when a deployment switches it on, the token must carry auth_time and it may be at most the configured limit plus 60 seconds oldper deployment
Expiry of an identity-provider sessionnone; the session lasts until the user logs out or an operator ends it (the same as social sign-in sessions)platform
Providers registered and enabled at onceno limitper deployment
E-mailed one-time code6 digits, valid for 10 minutesplatform
Authenticator code6 digits, time-based in 30-second steps; the current code and the ones one step before and after are acceptedplatform
Wrong attempts before the account is frozen and all its sessions ended5, counted separately for passwords, e-mailed codes and authenticator codes; the user is told by e-mailplatform

Reasons a sign-in is refused​

A refused sign-in returns the browser to the login page with ?error=<cause>; the page shows the text below.

CauseShown asMeaning
oidc_signup_disabledSign-up through this identity provider is disabled.No account matched and the provider has Allow signup off.
oidc_email_unverifiedYour identity provider reports your e-mail address as unverified.The e-mail claim is present but not asserted verified.
oidc_claim_missingThe identity provider did not share the required profile information (e-mail address).No e-mail claim after mapping.
oidc_provider_disabledThis identity provider is currently disabled.The provider's Enabled toggle is off.
oidc_provider_unavailableThe identity provider is currently unreachable.The provider's discovery document could not be fetched (HTTP 400).
oidc_state_mismatchThe sign-in attempt expired or was already used.See the 10-minute lifetime above (HTTP 401).
oidc_login_failedSigning in with the identity provider failed.Any other failure, including 401 oidc_exchange_failed and 401 oidc_claims_invalid from the token exchange.

Limits and known behaviour​

  • The operator console has no identity-provider button in 2.48.6; operators sign in with local accounts. An identity-provider login never grants an operator role, and an account created just in time has no password until the user sets one through the password-reset flow.
  • An unverified e-mail never links an existing account and never creates one. A missing email_verified claim counts as unverified, and there is no "trust this provider's e-mails" switch. If your provider asserts verification under another claim name, map email_verified to it (over the API; the console dialog maps e-mail and name only and preserves other mapped keys).
  • A mapped claim key replaces the default; when the mapped key is absent from the token the default key is not consulted.
  • Identities are keyed on the provider's subject. An e-mail change at the identity provider never re-links an identity; the subject match always wins.
  • A just-in-time creation that collides with an existing account holding the same e-mail unverified is refused with HTTP 409. Two simultaneous first logins of the same subject converge on one account.
  • Disabling a provider (Enabled off) hides its button and refuses both the start and the completion of a sign-in with 400 oidc_provider_disabled; a flow started just before the switch-off cannot complete.
  • Deleting a provider that still has linked identities is refused with 409 oidc_identities_exist. There is no API to remove a linked identity in 2.48.6; disable the provider instead, or have the operator remove the identities at database level.
  • The callback address is checked strictly at the start of each sign-in: the path must be exactly /auth/oidc/callback or /auth/oidc/{provider_id}/callback, with no query or fragment, and the origin must equal the origin of one of the deployment's configured application addresses (or the whole address must be one the deployment lists explicitly as an extra, matched byte for byte); anything else answers 400 oidc_redirect_uri_not_allowed. The address used for the token exchange is the one stored when the sign-in started, never one supplied at callback time.
  • Discovery runs at each step of a sign-in and is not cached: while the identity provider is unreachable, sign-ins answer 400 oidc_provider_unavailable; when it is back, sign-ins work again without restarting the API.
  • The client secret is read from the API's environment at sign-in time. A secret that is not set fails the sign-in server-side and shows up as the failure reason of Test discovery; the value itself is never shown or logged.
  • The ID-token age check is off by default because it requires the identity provider to emit auth_time; a deployment that switches it on against a provider that does not emit the claim refuses every sign-in.
  • Switching oidc_federation off makes GET /auth/oidc/providers, the authorize route and the callback answer 404 feature_disabled: the buttons disappear and sign-ins in progress cannot complete. Provider registrations, identity links and accounts created just in time are kept, existing sessions stay valid until they expire or are ended by an operator, and the provider routes in the console stay reachable.
  • Organisation auto-attach never removes a membership, and a failed attach does not fail the sign-in; it is logged.
  • There are no backup codes for the authenticator second factor. The login page points a user who lost the device to support. Disabling the second factor requires the current code.
  • Social sign-in sessions and identity-provider sessions skip the platform's second factor by design.
  • Planned: mapping identity-provider groups or claims to platform roles; SAML; directory synchronisation and de-provisioning (SCIM); CLI sign-in through the identity provider. None of these exist in 2.48.6.