Skip to Content
Auth for your appOpenID Connect reference

OpenID Connect reference

What Foir’s OpenID Connect provider answers, endpoint by endpoint. Hosted sign-in shows how to use it from a library or the SDK, and Connect an existing tool from a tool’s generic OpenID Connect login.

Discovery

GET {issuer}/.well-known/openid-configuration, and the same document at /.well-known/oauth-authorization-server. Production’s issuer is https://api.foir.dev. The document is the same for every app, whichever people it signs in.

On a project’s verified login domain, the domain is the issuer. Discovery at https://login.your-domain.com/.well-known/openid-configuration names https://login.your-domain.com as its issuer, and its authorize, token, userinfo and revocation endpoints are on the domain. Everybody who signs in through the domain is given access, ID and refresh tokens under that issuer, and refreshing keeps it. One key signs both issuers’ tokens, so jwks_uri is the same. Foir’s API, realtime and the endpoints below accept a token under a login domain’s issuer only for the project the domain serves. A domain that is removed stops being an issuer within a minute.

FieldValue
issuerThe issuer, with no trailing slash. Every token issued under it carries it as iss.
authorization_endpoint{issuer}/oauth/authorize
token_endpoint{issuer}/oauth/token
userinfo_endpoint{issuer}/oauth/userinfo
revocation_endpoint{issuer}/oauth/revoke
end_session_endpointThe end-session endpoint on the host that keeps the login page’s session. On a project’s own login domain, that domain’s.
jwks_uri{issuer}/.well-known/jwks.json
response_types_supportedcode
response_modes_supportedquery
grant_types_supportedauthorization_code, refresh_token, and the device code grant for Foir’s own tools
code_challenge_methods_supportedS256
token_endpoint_auth_methods_supported, revocation_endpoint_auth_methods_supportednone, client_secret_basic, client_secret_post
subject_types_supportedpublic
id_token_signing_alg_values_supportedRS256
scopes_supportedopenid, profile, email, offline_access
prompt_values_supportednone, login, consent, select_account
claims_parameter_supported, request_parameter_supported, request_uri_parameter_supportedfalse
frontchannel_logout_supported, backchannel_logout_supportedfalse

Authorization request

GET {issuer}/oauth/authorize

Parameter
client_id, redirect_uriRequired. The redirect URI must match one the app lists exactly. Until both check out, no error is sent to the app.
response_typeRequired, code.
code_challenge, code_challenge_methodRequired of a public app, with S256. A confidential app may leave them out; a challenge it sends is S256 and is checked at the token endpoint.
scopeIdentity scopes and permissions, space separated. See Scopes.
stateReturned unchanged.
nonceReturned in the ID token. Up to 512 characters.
promptnone goes on without a page or answers login_required, consent_required or interaction_required. login asks the person to sign in again. consent asks them again what the app may do, for an app your project does not run. select_account is how the page always behaves: it offers the person signed in beside another account, and never goes on by itself. none cannot be sent with another value, and any other value is refused.
max_ageSeconds. A sign-in older than this is not reused, and the person signs in again.
login_hintThe address the login page offers. The person can change it.
id_token_hint, display, ui_locales, claims_locales, acr_valuesAccepted and not used.
request, request_uri, registrationRefused with request_not_supported, request_uri_not_supported and registration_not_supported.
response_modeOnly query; anything else is refused.

Token endpoint

POST {issuer}/oauth/token, form encoded. A public app sends its client_id and no secret. A confidential app authenticates with one of its live secrets, by HTTP Basic with the client ID and secret form-encoded (client_secret_basic), or as client_id and client_secret in the form (client_secret_post), never both. A missing, wrong or revoked secret is answered 401 with invalid_client, and with a WWW-Authenticate: Basic challenge when the app tried Basic. The refresh grant and {issuer}/oauth/revoke authenticate the app the same way.

The authorization_code grant takes code, redirect_uri, and code_verifier when the sign-in sent a challenge. A code from a sign-in that sent none is traded only by a confidential app with its secret, and a verifier sent for it is refused. A code redeems once, within 60 seconds. Presented a second time it is refused with invalid_grant, and the sign-in its first use was given ends: its refresh token is refused and userinfo refuses its access token, as if the person had signed out. The response:

Field
access_tokenA bearer for Foir’s public API, valid for 15 minutes.
refresh_tokenRotates on every use, and presenting a used one ends the whole family. It lasts up to 30 days, and ends when the person signs out.
id_tokenWhen the sign-in asked for openid.
expires_in, token_typeBearer.
scopeThe identity scopes the app was given, then what the access token carries.

The refresh_token grant takes refresh_token. Its answer has a new ID token for the same sign-in, with the same auth_time and no nonce.

ID token

Signed RS256 with a key from jwks_uri, named by its kid.

Claim
iss, aud, sub, iat, expThe issuer, the app’s client ID, the person’s ID, and the token’s lifetime, which matches the access token’s.
auth_timeWhen the person signed in. A session reused from the login page keeps the time they first signed in.
nonceThe authorization request’s.
amrHow they signed in, as RFC 8176 values such as pwd, otp and mfa.
at_hashThe hash of the access token issued with it.
sidNames the session they signed in with, for signing out.
org_idThe organization the sign-in is for: the one the sign-in named, or the one the person chose at the login page when the app asks which. Absent for a sign-in for the whole project, and on a refresh’s ID token: by then the person may stand elsewhere. No token names one where it is honoured: each request names where it stands. See Where a person may go.
email, email_verifiedUnder email.
name, given_name, family_name, picture, localeUnder profile, where the person has them. picture is always the web address of an image.

Userinfo

GET or POST {issuer}/oauth/userinfo with the access token as a bearer. It answers sub and the claims of the identity scopes the app was given, kept to what the person agrees to now. A token whose session has ended, whose app was disabled, or whose person’s account is closed is answered 401 with invalid_token. A token from a sign-in that did not ask for openid is answered 403 with insufficient_scope.

End session

GET or POST the end_session_endpoint, with id_token_hint, client_id, post_logout_redirect_uri and state, all optional:

  • With id_token_hint, Foir ends the session the token names, wherever the person signed in. The token may be expired. client_id must be the token’s audience when you send both.
  • The login page’s own session in this browser ends too, unless the hint names somebody else.
  • post_logout_redirect_uri must be on the origin of one of the app’s redirect URIs. state comes back with it. Without it, the answer is 204.

Keys

jwks_uri lists every key Foir signs with: RS256 keys for ID tokens and EdDSA keys for its own access tokens and scoped tokens. A new key appears in the set before anything is signed with it, and an old one stays until every token it signed has expired. A kid always names the same key. Cache the set and fetch it again when a token names a kid you have not seen.

Last updated on