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.
Before you begin
Section titled “Before you begin”- Who can do it: a realm administrator (a group holding
RealmOwner);RealmViewercan 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.
How it works
Section titled “How it works”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"}| Claim | What it says |
|---|---|
sub | The user, by their ID in the realm |
aud | The app it was issued to |
auth_time | When the user signed in |
nonce | The app’s own nonce, on the first ID token only, to tie it to the app’s sign-in |
amr | The sign-in methods used, as the realm’s amrValues names them. Left out when none is named |
acr | The sign-in level reached (step-up). Left out when the realm names none |
sid | The session, as a logout token names it |
at_hash | A 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:
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.
Which details each scope releases
Section titled “Which details each scope releases”The realm starts with a mapping for the four standard scopes, and offers profile and email out of the box:
| Scope | Releases | Offered by default |
|---|---|---|
profile | name, given and family name, preferred username, locale, time zone | Yes |
email | email address | Yes |
phone | phone number | Add phone to the realm’s scopes |
address | postal address | Add 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.
Set it up
Section titled “Set it up”These steps use the admin API; Call the API shows how to get a session.
- Offer OpenID Connect in the realm:
openidamong itsscopes, andauthorization_codeamong itsgrantTypes(both by default). Change the realm withPATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings. Both are lists: read them first withGET, and send back the whole list, since a list you send replaces the realm’s list. - Choose what each scope releases in the realm’s
scopeClaims, and where each detail is read from inclaimAttributes. - On the client (
https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client), listopenidand the detail scopes among itsscopes, and set its signing choices if the defaults don’t suit.
| Where | Setting | What it does |
|---|---|---|
| Realm | grantTypes includes authorization_code | Needed for OpenID Connect at all |
| Realm | scopes includes openid | Offers OpenID Connect, and publishes its discovery document |
| Realm | claims | The details the realm may release |
| Realm | scopeClaims | Which details each scope releases |
| Realm | claimAttributes | Which attribute each detail is read from |
| Realm | idTokenScopeClaims | Puts the details in the ID token as well as userinfo (default off) |
| Realm | idTokenLifetimeSecs | How long an ID token is valid (default 300) |
| Realm | amrValues | Names each sign-in step in the token’s amr (for example pwd, otp) |
Realm (keySettings) | algorithm.oauth2.idToken | The algorithms ID tokens and userinfo answers may be signed with: RS256 and ES256 by default, PS256 if you add it. RS256 is always offered |
| Client | idTokenSignedResponseAlg | RS256 (default) or ES256; PS256 once the realm offers it |
| Client | userinfoSignedResponseAlg | Answers this app’s userinfo as a signed JWT. Absent, userinfo answers JSON. Must be one the realm offers |
| Client | scopeClaims | For each scope it names, the details this app gets in place of the realm’s. Only details the realm offers |
What the user sees
Section titled “What the user sees”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.
Limits and defaults
Section titled “Limits and defaults”| Setting or limit | Default | Range |
|---|---|---|
idTokenLifetimeSecs | 300 | 1 to 3,600 |
idTokenScopeClaims | off: details at userinfo only | on or off |
claims: details the realm may release | sub, name, given_name, family_name, preferred_username, locale, zoneinfo, email, phone_number | yours to set |
| ID token signing | RS256 for a client, ES256 under FAPI 2.0 | RS256, ES256, PS256 once offered |
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| No ID token in the answer | openid wasn’t asked for or isn’t among the client’s or the realm’s scopes | Add openid to both, and ask for it |
server_error and no tokens at all | The client’s idTokenSignedResponseAlg isn’t one the realm offers | Set the client’s algorithm to one in keySettings.algorithm.oauth2.idToken |
A detail, such as email, is missing | The scope that releases it wasn’t granted, the realm doesn’t offer the detail, or the user’s attribute is empty | Ask for the scope; check claims, scopeClaims and claimAttributes |
Userinfo answers 401 | The token lacks openid, is a service’s, or has expired | Call it with a user’s access token that carries openid |
Audit record
Section titled “Audit record”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.
Good to know
Section titled “Good to know”- OpenID Connect is offered only while the realm takes the authorization code grant and lists
openidamong 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, wheneveropenidwas granted. - An app can never be given a detail the realm doesn’t offer, whatever its own
scopeClaimssays. - One list of algorithms signs both the ID token and userinfo: the realm’s
keySettings.algorithm.oauth2.idToken. - A client whose
idTokenSignedResponseAlgthe realm doesn’t offer gets no ID token. The token request fails withserver_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 onlyES256orPS256inidTokenSignedResponseAlganduserinfoSignedResponseAlg.
Related
Section titled “Related”- Choose which details an app receives: scopes and claims, step by step.
- Choose how ID tokens are signed: the realm’s and the app’s algorithms.
- Name users by your own directory’s attributes: re-point claims to your attributes.
- Sign users in to a web app: the whole sign-in, start to finish.
- Consent: what the user sees before the app gets anything.
- Access tokens: what the access token beside the ID token carries.