This guide is written by the team that builds Casdoor and describes the standards as published (listed under Sources), with notes on how Casdoor implements them as of November 1, 2026. Spotted a mistake? Tell us.
OpenID Connect (OIDC) is an identity layer on top of OAuth 2.0. It defines how an application learns who the user is, in a standard and verifiable way: an ID token with the user's identity, a userinfo endpoint, and a discovery document that tells clients where everything lives.
OAuth 2.0 gives you an access token that says "this client may call this API". OIDC adds: "and here is a signed statement that this is Alice, issued for this application, at this time."
The pieces
ID token. A signed JSON Web Token (JWT) issued by the OpenID provider. The client validates it and reads the claims:
| Claim | Meaning |
|---|---|
iss |
Issuer identifier |
sub |
Subject — a stable user identifier |
aud |
Audience — the client ID this token was issued for |
exp, iat |
Expiry and issue time |
nonce |
Binds the token to the request that produced it |
name, email, picture |
Profile claims, if the requested scopes allow them |
Access token. Still an OAuth token, used to call APIs. It is usually not a JWT, and clients should treat it as opaque.
Userinfo endpoint. An API that returns profile claims for the access token, for data you do not want in the ID token.
Discovery document. At /.well-known/openid-configuration, the provider publishes its issuer, authorization endpoint, token endpoint, userinfo endpoint, supported scopes and JWKS URI (where the signing keys live). A client that supports discovery only needs the issuer URL to be configured.
The flow
For web, mobile and single-page apps, the standard flow is authorization code with PKCE:
- The client redirects to the authorization endpoint with client ID, redirect URI, scopes (
openidis required), state and a PKCE code challenge. - The user authenticates at the provider.
- The provider redirects back with a short-lived code.
- The client exchanges the code (plus the PKCE verifier) at the token endpoint.
- The response contains an ID token, an access token, and optionally a refresh token.
Native and single-page apps must not ship a client secret; PKCE takes its place.
Validating an ID token
Getting this wrong is how OIDC integrations become insecure. The client must check:
- Signature — against the provider's JWKS, and the key must match the token's header.
- Issuer —
issequals the expected provider. - Audience —
audcontains this client's ID. - Expiry — the token is within
exp(with a small clock skew). - Nonce — matches the value the client sent in the request.
- Algorithms — reject
noneand unexpected algorithms.
Only then is sub trustworthy as the user identifier. Treat email as an attribute, not a key: emails change and can be reassigned.
Scopes and claims
openid— required; requests an ID token.profile— name, picture, locale and similar claims.email— email and email_verified.address,phone— the obvious.
Anything beyond these is provider-specific. Keep the requested scopes minimal: every additional scope is data the user is asked to approve.
OIDC vs OAuth vs SAML
- OAuth 2.0 — authorization for APIs.
- OIDC — authentication on top of OAuth; the default for new applications.
- SAML — XML-based enterprise SSO; still the language of procurement.
A single identity provider usually speaks all three. Casdoor, for example, issues OIDC tokens for your apps and SAML assertions for applications that require SAML, from the same user store.
Read more: OAuth vs OIDC, what OAuth 2.0 is and SAML vs OIDC.
Casdoor is open source and self-hostable, with a hosted option from $9 per month and no per-user fees.
Sources
- OpenID Connect Core 1.0
- OpenID Connect Discovery 1.0
- RFC 7636: Proof Key for Code Exchange (PKCE)
- RFC 6749: The OAuth 2.0 Authorization Framework
Product names are trademarks of their respective owners.