Skip to content
Workforce IdentityMarkdown

OpenID Connect sign-in

Your apps learn who signed in, when and how, and receive only the user details you choose to release.

AvailableAPIOpenID Connect Core 1.0

OpenID Connect tells an app who is using it, not only what it may do. When an app asks for the openid scope in a browser sign-in, it receives an ID token beside the access token: who signed in, when, and how (a password, or a password and a one-time code). The app can also ask the realm’s userinfo endpoint for the user’s details, such as name, email and phone.

Most apps that sign users in want this. You decide which details each scope releases, realm-wide and per app, and which of your users’ attributes each detail is read from.

  • Who can do it: a realm administrator (a group holding RealmOwner); RealmViewer can read the settings but not change them.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: the app signs users in with authorization code with PKCE.

The app asks for openid in its sign-in, with a nonce of its own, and receives an id_token in the token response. Decoded, the ID token’s claims look like this:

{
"iss": "https://foobar.cvyuh.com/oauth2",
"sub": "3f9b2c71-8d4e-4a6f-b1c2-7e5d9a0f3b48",
"aud": ["team-wiki"],
"iat": <unix time>,
"exp": <iat + 300>,
"auth_time": <unix time of the sign-in>,
"nonce": "n-0S6_WzA2Mj",
"amr": ["pwd", "otp"],
"acr": "urn:example:acr:mfa",
"sid": "6f1e2d3c-4b5a-4968-8776-a5b4c3d2e1f0",
"at_hash": "77QmUPtjPfzWtF2AnpK9RQ"
}
ClaimWhat it says
subThe user, by their ID in the realm
audThe app it was issued to
auth_timeWhen the user signed in
nonceThe app’s own nonce, on the first ID token only, to tie it to the app’s sign-in
amrThe sign-in methods used, as the realm’s amrValues names them. Left out when none is named
acrThe sign-in level reached (step-up). Left out when the realm names none
sidThe session, as a logout token names it
at_hashA hash of the access token it came with, so the app can tell the two belong together

The access token from the same sign-in may be presented at userinfo:

Terminal window
curl https://foobar.cvyuh.com/oauth2/userinfo \
-H "Authorization: Bearer eyJhbGciOiJFUzI1NiIs…"
{
"sub": "3f9b2c71-8d4e-4a6f-b1c2-7e5d9a0f3b48",
"name": "Maya Chen",
"given_name": "Maya",
"family_name": "Chen",
"preferred_username": "maya",
"email": "maya@example.com"
}

An app can ask for its userinfo answer signed, as a JWT (application/jwt) naming the realm (iss) and the app (aud), by setting userinfoSignedResponseAlg. The discovery document is at https://foobar.cvyuh.com/oauth2/.well-known/openid-configuration.

The realm starts with a mapping for the four standard scopes, and offers profile and email out of the box:

ScopeReleasesOffered by default
profilename, given and family name, preferred username, locale, time zoneYes
emailemail addressYes
phonephone numberAdd phone to the realm’s scopes
addresspostal addressAdd address to the realm’s scopes and claims

A detail is released only if the realm lists it among its claims and the user has it. A scope you add yourself releases nothing until you map it to claims in scopeClaims. If your users’ attributes have other names, re-point each claim to the attribute that holds it with claimAttributes. By default the details go only to userinfo; idTokenScopeClaims puts them in the ID token too.

One app can be given less than the realm releases: its own scopeClaims replaces the realm’s list for each scope it names, within the details the realm offers.

These steps use the admin API; Call the API shows how to get a session.

  1. Offer OpenID Connect in the realm: openid among its scopes, and authorization_code among its grantTypes (both by default). Change the realm with PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings. Both are lists: read them first with GET, and send back the whole list, since a list you send replaces the realm’s list.
  2. Choose what each scope releases in the realm’s scopeClaims, and where each detail is read from in claimAttributes.
  3. On the client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client), list openid and the detail scopes among its scopes, and set its signing choices if the defaults don’t suit.
WhereSettingWhat it does
RealmgrantTypes includes authorization_codeNeeded for OpenID Connect at all
Realmscopes includes openidOffers OpenID Connect, and publishes its discovery document
RealmclaimsThe details the realm may release
RealmscopeClaimsWhich details each scope releases
RealmclaimAttributesWhich attribute each detail is read from
RealmidTokenScopeClaimsPuts the details in the ID token as well as userinfo (default off)
RealmidTokenLifetimeSecsHow long an ID token is valid (default 300)
RealmamrValuesNames each sign-in step in the token’s amr (for example pwd, otp)
Realm (keySettings)algorithm.oauth2.idTokenThe algorithms ID tokens and userinfo answers may be signed with: RS256 and ES256 by default, PS256 if you add it. RS256 is always offered
ClientidTokenSignedResponseAlgRS256 (default) or ES256; PS256 once the realm offers it
ClientuserinfoSignedResponseAlgAnswers this app’s userinfo as a signed JWT. Absent, userinfo answers JSON. Must be one the realm offers
ClientscopeClaimsFor each scope it names, the details this app gets in place of the realm’s. Only details the realm offers

The realm’s sign-in page, then, the first time, the consent page listing the details the app asks for (name, email, phone), which the user allows or refuses (Consent). What the app shows the user afterwards comes from the ID token and userinfo.

Setting or limitDefaultRange
idTokenLifetimeSecs3001 to 3,600
idTokenScopeClaimsoff: details at userinfo onlyon or off
claims: details the realm may releasesub, name, given_name, family_name, preferred_username, locale, zoneinfo, email, phone_numberyours to set
ID token signingRS256 for a client, ES256 under FAPI 2.0RS256, ES256, PS256 once offered
SymptomCauseFix
No ID token in the answeropenid wasn’t asked for or isn’t among the client’s or the realm’s scopesAdd openid to both, and ask for it
server_error and no tokens at allThe client’s idTokenSignedResponseAlg isn’t one the realm offersSet the client’s algorithm to one in keySettings.algorithm.oauth2.idToken
A detail, such as email, is missingThe scope that releases it wasn’t granted, the realm doesn’t offer the detail, or the user’s attribute is emptyAsk for the scope; check claims, scopeClaims and claimAttributes
Userinfo answers 401The token lacks openid, is a service’s, or has expiredCall it with a user’s access token that carries openid

Each sign-in’s tokens are one TOKEN_ISSUED record, naming the scopes granted. Userinfo calls aren’t recorded one by one. Changes to the realm’s claims or the client’s are in Audit → Config.

  • OpenID Connect is offered only while the realm takes the authorization code grant and lists openid among its scopes. Otherwise there is no OpenID discovery document.
  • An ID token lives five minutes by default.
  • Only users get ID tokens. An agent or a service never does.
  • Userinfo takes only a token that carries openid, is about a user, and was issued for this realm’s userinfo. A token is, whenever openid was granted.
  • An app can never be given a detail the realm doesn’t offer, whatever its own scopeClaims says.
  • One list of algorithms signs both the ID token and userinfo: the realm’s keySettings.algorithm.oauth2.idToken.
  • A client whose idTokenSignedResponseAlg the realm doesn’t offer gets no ID token. The token request fails with server_error, and the app receives no tokens, rather than an ID token signed with another algorithm. Keep the client’s algorithm in the realm’s list.
  • A client under the FAPI 2.0 profile defaults to ES256, and may name only ES256 or PS256 in idTokenSignedResponseAlg and userinfoSignedResponseAlg.