Documentation / v1 / Connections

Connect an OpenID Connect provider

Let people from an outside OpenID Connect provider sign in to a directory. Built and tested locally; no real provider has been connected.

State in this release

Built and tested locally against a test provider: discovery, the authorization code flow with PKCE, ID token verification, attribute mapping, account linking and the hosted sign-in journey. No real provider was used, so interoperability with a particular product is unverified. Group synchronisation, attribute refresh on later logins and deleting a connection are built and tested locally the same way; the console has no screen for them yet, so use the API or the generated clients.

Before you start

You need a directory and an account role of owner, administrator or developer; an OAuth client of your own in that directory with a registered redirect URI; a provider account that can register a confidential client; and a directory factor policy that lists the federated method. Changes take a fresh action proof where the directory asks for one, sent in the X-Auth-Proof header.

Create the connection

Send the request below to the directory's connections route with the strategy, a display name, the provider settings and the client secret. The issuer must be an https URL with no query or fragment; the service discovers the endpoints from it and refuses a discovery document whose issuer differs by a character. Scopes must include openid. The token endpoint method is client_secret_basic or client_secret_post. To skip discovery give the authorization, token and JWKS endpoints together, or none. The answer contains callback_url, the redirect URI to register at the provider, exactly. The secret is stored encrypted and never returned.

Request · http
POST /v1/console/accounts/{account_id}/directories/{directory_id}/connections
Content-Type: application/json
X-Auth-Proof: <receipt, when the directory asks for one>

{
  "strategy": "oidc",
  "display_name": "Acme sign-in",
  "config": {
    "issuer": "https://idp.example.com",
    "client_id": "client-id-from-the-provider",
    "scopes": [
      "openid",
      "email",
      "profile"
    ],
    "token_endpoint_auth_method": "client_secret_basic"
  },
  "client_secret": "secret-from-the-provider",
  "jit_enabled": true
}

Map the attributes

A new connection starts with a default mapping for email, verified flag, names, locale, phone and groups. Replace it with a list of rules. Each rule produces one attribute from a claim, a constant or a join, through the transforms lower, trim or regex_extract. Several rules for one target are fallbacks, and a required rule fails the login naming the attribute. There is no expression language. Test a mapping with sample claims at the mapping preview route before saving.

Groups and profile attributes

Two optional settings, both off, set with the same PATCH. sync_groups makes the mapping's groups attribute the person's membership of the groups this connection owns at each sign-in; a name the connection has no group for is created, the mapping must have a rule for groups, and a sign-in with no groups removes the person from the connection's groups, and turning sync_groups off removes everyone from them. refresh_attributes updates the display name from the provider on later sign-ins; the email address and whether it is verified are never changed this way.

A connection's group is its own. It is found by connection and name, so a console group, a SCIM group or another connection's group with the same name is never read or changed. The provider can only name groups: a role comes from a role mapping an administrator adds to that connection's group, and it applies only while the connection is enabled, so disabling a connection ends the roles its groups gave at the next token. The groups list shows source_connection_id, and the console cannot rename those groups or change their members. Names are untrusted text: blank names, names over 256 characters and names with control characters are skipped, names that differ only in case are one group, at most 100 names are used per sign-in and one connection owns at most 500 groups.

Deleting a connection is final for sign-in. It refuses every login, is no longer listed, ends the sessions it created, removes the people it put in its own groups and in the SCIM groups its token created, releases its domain claims and revokes any SCIM token bound to it. Its record, its federated identities and its groups stay for audit. Disable it instead to keep the option of coming back.

Scope the connection to an organization

Optional. Send organization_id when you create the connection, the id of an active organization of the same directory, to make it that organization's own provider. It is set at creation and cannot be changed; the view returns it, null for a connection of the whole directory.

The hosted sign-in page lists a directory-wide connection for every request. A connection of an organization is listed, and found by a verified email-domain claim, only when the request carries the organization parameter (its id or slug) of that organization: with none, with another organization's, or with one that is unknown, suspended or archived it is neither offered nor discovered. The same rule is checked at the start route and again when the provider answers. When the request names an organization and carries a login_hint that is an email address, the Continue with buttons pass it to the provider.

A person this connection creates becomes an active member of the organization in the same transaction, and identity.linked names it. Only creating the account adds a member: signing in again never re-adds someone an administrator removed. Tokens still carry org_id and org_roles only for a member, checked when the code is issued and again at the token endpoint. Groups the connection owns belong to the organization. A SAML sign-in the identity provider starts has no application request to name an organization, so a connection of an organization never serves one: allow_idp_initiated is refused for it.

Claim the email domain

Claiming a domain returns a DNS TXT record to publish at _bd-challenge.<domain> with the value bd-verify=<token>. Verification needs the operator to set AUTH_SERVICE_DOMAIN_VERIFICATION_DOH_URL; unset, the verify route answers 503 and nothing is verified. A verified claim enables account linking and sends people who type an address at that domain straight to the connection.

Enable and test

Enabling is refused until a client secret is set. On the hosted sign-in page choose Continue with the connection. The browser goes to the start route with your request parked in a single-use ten-minute state bound to that browser; the callback then checks the state, the RFC 9207 iss parameter, the code exchange and the ID token (RS256, PS256 or ES256; issuer, audience, authorized party, expiry, subject and nonce). The person returns to your authorization request with a hosted session whose method is federated; the ID token amr is fed and carries no acr.

  1. Sign in with a test account at the provider.
  2. Sign in with an address that already belongs to a directory account and confirm the person is asked to prove that account and nothing is linked until they do.
  3. Disable the connection and confirm the sessions it created have ended.

When it fails

Every failure is a hosted error page and never a redirect to a URL the provider supplied. A mapping without a required attribute names it. The failed-login event carries a reason code and never the provider's text. Usual causes: a redirect URI that differs from callback_url, a discovery issuer that differs from the configured one, a clock more than 60 seconds off, or a provider that returns no email.