Skip to content
Tech Interview Prep
Technical interview guide

SSO & Federation Protocols (SAML, OIDC)

How a user authenticates once with an identity provider and gets trusted access across many applications.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v6
Editorial status
Reviewed

Scope: OIDC Core 1.0, OAuth 2.0 with RFC 9700 BCP, SAML 2.0, SCIM 2.0, and NIST SP 800-63C-4 guidance current 2026-09-04.

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 scope and aud. 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:

code_challenge=BASE64URL(SHA256(code_verifier))\text{code\_challenge} = \text{BASE64URL}(\text{SHA256}(\text{code\_verifier}))

The verifier is 43 to 128 characters (RFC 7636). The IdP's authorization code is short-lived and single-use.

How it works

  1. The RP generates state, nonce and code_verifier for each login, stores them in that browser's session, and redirects with code_challenge and code_challenge_method=S256.
  2. The IdP authenticates the user and redirects to the registered callback with code and state.
  3. The RP checks state against the session, then POSTs code and the verifier to the token endpoint of the issuer it started with.
  4. The RP validates the ID token: signature from that issuer's JWKS, iss, aud equal to its own client ID, azp, exp, nonce, and auth_time or acr where required.
  5. Only then does it create a local session and map roles locally.
no yes Start login: store state, nonce, verifier IdP authenticates user Redirect to callback with code and state state matches session? Reject Token POST: code and verifier to issuer Validate ID token: sig, iss, aud, azp, exp, nonce Create local session, 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

SituationChooseWhy
New browser or native app you controlOIDC code flow with PKCEShort code, back-channel exchange, JWT tooling
Partner that offers only SAMLSAML 2.0 Web Browser SSOIt is the protocol the IdP supports; XML validation is the risk
Calling your own APIAccess tokenaud names the API
Accepting an arbitrary tenant's IdPOnly with a pinned, allowlisted issuerDiscovery data can redirect trust
Deprovisioning a leaverSCIM plus revocation and per-request checksSSO login only blocks the next login
Implicit or password grantNot for new systemsSuperseded by code flow with PKCE

Traps interviewers probe

  1. Treating an access token as a login. Fix: create the session only from an ID token from the issuer you started with, with aud equal to your client ID and a matching nonce.
  2. One global verifier or state variable. Fix: store state and the verifier per transaction in the session. A second login must not overwrite the first, or concurrent logins break each other.
  3. Trusting discovery from user input. Fix: allowlist issuers, pin the issuer string, and require the returned issuer to match exactly. Reject jwks_uri and endpoints that are not from pinned configuration.
  4. 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.
  5. Assuming SSO deprovisions. Fix: SCIM active=false must revoke sessions and refresh tokens, and local authorization must check active on 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:

  1. OIDC authenticates on top of OAuth 2.0 with JWTs. SAML carries signed XML assertions.
  2. Each login binds state, nonce and PKCE to that browser.
  3. Validate the token against the issuer's keys, iss, aud, nonce and exp.
  4. Create a local session and map roles deny-by-default.
  5. 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.