{}DSA Atlas

Advanced Authentication — OAuth, OIDC, SSO, MFA & Passkeys

OAuth 2.0 roles and flows (authorization code + PKCE, client credentials, device code, refresh), what OAuth 2.1 and the RFC 9700 security BCP changed, OpenID Connect and ID tokens, SSO with OIDC and SAML, MFA methods, passkeys/WebAuthn, API keys, service-to-service and workload identity, token exchange and sender-constrained tokens.

Advanced8 interview questions

OAuth 2.0: the cast

Resource ownerthe user Clientapp wanting access Authorization serverlogin, consent, tokens Resource serverthe API (validates tokens) access token trust (JWKS / introspection)
The user never gives the client their password; the client gets a scoped token instead.
TermMeaning
Scopepermission requested (orders:read, openid email)
Access tokencredential to call the API (JWT or opaque)
Refresh tokenobtain new access tokens without user interaction
Confidential clientcan keep a secret (server-side app)
Public clientcan't (SPA, mobile, CLI)
Redirect URIwhere the AS sends the user back — must be pre-registered and matched exactly

Authorization code + PKCE

Browser Client app Authorization srv API 1. make code_verifier, challenge = S256(verifier), state 302 to /authorize 2. /authorize?code_challenge&scope&state 3. user logs in + consents 4. 302 redirect_uri?code=abc&state code, state (check!) 5. POST /token code + verifier 6. check S256(verifier) = challenge access + refresh (+ ID token) 7. API call: Authorization: Bearer … data (after validating iss, aud, exp, scope)
Front channel (redirects) carries only a short-lived code; tokens travel on the back channel.
Python
import base64, hashlib, secrets

verifier = base64.urlsafe_b64encode(secrets.token_bytes(32)).rstrip(b"=").decode()
challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode()
state = secrets.token_urlsafe(16)
authorize_url = (
    "https://auth.example.com/authorize?response_type=code"
    f"&client_id=web-app&redirect_uri=https://app.example.com/callback"
    f"&scope=openid%20profile%20orders:read&state={state}"
    f"&code_challenge={challenge}&code_challenge_method=S256"
)

Other grants

GrantWhoNotes
Authorization code + PKCEusers via any appthe default
Client credentialsmachine-to-machineno user; token represents the client
Device authorizationTVs, CLIs, IoTuser approves on a phone/laptop with a short code
Refresh tokenany long-lived sessionrotate; sender-constrain public clients
Token exchange (RFC 8693)service calling downstream on behalf of a usernarrower scope, new audience
Implicit—removed in OAuth 2.1 (tokens leaked in URLs)
Password (ROPC)—removed in OAuth 2.1 (app sees the password)

OAuth 2.1 and the security BCP

OAuth 2.1 (still an IETF draft in 2026) consolidates a decade of security lessons; RFC 9700 (Best Current Practice for OAuth 2.0 Security, January 2025) is already published and widely adopted:

  • PKCE required for authorization code flows.
  • Exact redirect URI matching.
  • Implicit and password grants removed.
  • Bearer tokens never in query strings.
  • Refresh tokens for public clients must be rotated or sender-constrained (DPoP, RFC 9449, or mTLS-bound tokens, RFC 8705).

OpenID Connect (authentication)

JSON
{
  "iss": "https://accounts.example.com",
  "sub": "248289761001",
  "aud": "web-app",
  "exp": 1791392400,
  "iat": 1791388800,
  "nonce": "n-0S6_WzA2Mj",
  "auth_time": 1791388790,
  "amr": ["pwd", "otp"],
  "email": "asha@example.com",
  "email_verified": true
}
ID tokenAccess token
Audiencethe client appthe API
Purpose"who logged in""may call this API"
Formatalways JWTJWT or opaque
Validatesignature, iss, aud=client_id, exp, noncesignature/introspection, iss, aud=API, scopes

Identify users by iss + sub, never by email (emails change and can be reassigned).

SSO: OIDC vs SAML

Identity providerOkta · Entra ID · Google Jira Slack Your SaaS Internal tools log in once at the IdP; apps trust its signed assertions/ID tokens · SCIM provisions/deprovisions users
One identity, many apps.
SAML 2.0OIDC
FormatXML assertions, XML-DSigJSON / JWT
Built onits own bindings (HTTP-POST/Redirect)OAuth 2.0
Clientsbrowser web appsweb, mobile, SPAs, APIs
Complexityhigh (XML canonicalisation pitfalls)moderate
Whereenterprise B2B SSOmodern apps, consumer login, B2B too

Multi-factor authentication

FactorSecurityNotes
SMS OTPweakSIM swap, interception; better than nothing
Email magic link / OTPmoderateas strong as the email account
TOTP (authenticator app, RFC 6238)goodphishable (real-time relay)
Push approvalgoodbeware MFA fatigue → number matching
WebAuthn / passkeys / security keysbestphishing-resistant, origin-bound

Passkeys (WebAuthn)

Authenticator Browser Server (RP) challenge (random), rpId=example.com sign for origin example.com user verifies (Face ID / PIN) signature with private key assertion → verify with stored public key
Login with a passkey: no shared secret ever crosses the network, and the signature is bound to the real origin.

API keys

Text
sk_live_51Hc… (shown once)        → store: prefix "sk_live_51Hc" + SHA-256(full key)
Authorization: Bearer sk_live_51Hc…

Best practices: prefixes for scanning and environment, hash at rest, scopes, multiple keys per account for rotation, last-used tracking, per-key rate limits, revocation, never in URLs or client-side code.

Service-to-service and workload identity

MethodStrengthNotes
Shared static secret / basic authweakleaks, hard rotation
API key per servicemoderatestill static
OAuth client credentials (+ private_key_jwt)strongshort-lived, audience-scoped tokens
mTLS with SPIFFE IDs (service mesh)strongautomatic rotation, identity in the certificate
Cloud workload identity federationstrongno long-lived cloud keys
Signed requests (HMAC, AWS SigV4)strongintegrity + replay protection with timestamps

Interview questions

0 / 8 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.