Overview
Curated: · Written: · Reviewed:
SSO & Federation Protocols (SAML, OIDC)
In one line
An identity provider (IdP) authenticates the user once and sends a signed statement to each relying party (RP). Reach for OIDC for new browser and native logins, and for SAML when a partner's IdP only speaks SAML. The RP still validates every token or assertion, then creates its own session and resolves its own local permissions.
Key definitions
- ID token: a signed JWT for the client, stating who authenticated and when. It is not an API credential.
- Access token: a bearer credential for a resource server, limited by
scopeandaud. It says nothing about a login at your client. iss+sub: the stable external identity key. Email is not one.state,nonce, PKCE verifier: per-transaction values that bind the response to the login the browser started.- InResponseTo / Recipient / Audience: SAML's bindings of a response to your request, your ACS URL and your entity ID.
- SCIM 2.0: a provisioning protocol for create, update and deactivate. It is not SSO.
Formulas and complexity
PKCE with S256 checks the verifier at the token endpoint:
The verifier is 43 to 128 characters (RFC 7636). The IdP's authorization code is short-lived and single-use.
How it works
- The RP generates
state,nonceandcode_verifierfor each login, stores them in that browser's session, and redirects withcode_challengeandcode_challenge_method=S256. - The IdP authenticates the user and redirects to the registered callback with
codeandstate. - The RP checks
stateagainst the session, then POSTscodeand the verifier to the token endpoint of the issuer it started with. - The RP validates the ID token: signature from that issuer's JWKS,
iss,audequal to its own client ID,azp,exp,nonce, andauth_timeoracrwhere required. - Only then does it create a local session and map roles locally.
For SAML, validate the signature on the element you consume, plus Issuer, Audience, Recipient, InResponseTo for SP-initiated logins, and NotBefore/NotOnOrAfter within a documented skew. Track assertion IDs in a store every node shares, and parse XML with external entities disabled.
When to use and when not to
| Situation | Choose | Why |
|---|---|---|
| New browser or native app you control | OIDC code flow with PKCE | Short code, back-channel exchange, JWT tooling |
| Partner that offers only SAML | SAML 2.0 Web Browser SSO | It is the protocol the IdP supports; XML validation is the risk |
| Calling your own API | Access token | aud names the API |
| Accepting an arbitrary tenant's IdP | Only with a pinned, allowlisted issuer | Discovery data can redirect trust |
| Deprovisioning a leaver | SCIM plus revocation and per-request checks | SSO login only blocks the next login |
| Implicit or password grant | Not for new systems | Superseded by code flow with PKCE |
Traps interviewers probe
- Treating an access token as a login. Fix: create the session only from an ID token from the issuer you started with, with
audequal to your client ID and a matchingnonce. - One global verifier or state variable. Fix: store
stateand the verifier per transaction in the session. A second login must not overwrite the first, or concurrent logins break each other. - Trusting discovery from user input. Fix: allowlist issuers, pin the issuer string, and require the returned
issuerto match exactly. Rejectjwks_uriand endpoints that are not from pinned configuration. - Merging accounts on email. Fix: key on issuer plus
sub. Link accounts only after proof of control of both identities, or through an admin workflow. - Assuming SSO deprovisions. Fix: SCIM
active=falsemust revoke sessions and refresh tokens, and local authorization must checkactiveon each request.
Interview tips
Opening line: "Authentication is the ID token from the issuer I started with. Authorization is local. Access tokens are for APIs."
Expected follow-ups: validating the signature versus the signed content (XML wrapping); SP-initiated versus IdP-initiated login; when a terminated user is actually denied; key rotation with cached JWKS; why logout is not global.
30-second outline:
- OIDC authenticates on top of OAuth 2.0 with JWTs. SAML carries signed XML assertions.
- Each login binds
state,nonceand PKCE to that browser. - Validate the token against the issuer's keys,
iss,aud,nonceandexp. - Create a local session and map roles deny-by-default.
- Lifecycle comes from SCIM and revocation, not from SSO alone.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.