Proving who is on the other end of the request, and remembering it across the next thousand. The first gate every request passes through.
← Back to Server SideServer stores a session record (Redis, DB). The client holds only an opaque session_id in a cookie.
Pros: trivially revocable, small cookie, no secrets in the client.
Cons: needs shared session store across instances; sticky sessions get awkward at scale.
Server signs a JSON payload; client carries it. Server verifies signature on each request — no lookup needed.
Pros: horizontally scalable, friendly to microservices and mobile.
Cons: revocation is hard (use short TTLs + refresh tokens); payload is visible to whoever holds the token.
OAuth 2.0 is a delegation protocol — "let app X call API Y on my behalf." It issues access tokens. OIDC is a thin identity layer on top of OAuth 2.0 that adds an ID token (a JWT describing the user). If you want "Sign in with Google," you want OIDC.
Pre-OIDC enterprise SSO standard, XML-based. Still everywhere in B2B and corporate IT. If your customer is a Fortune-500 buyer, expect a SAML integration request even in 2026.
A signed, base64-encoded payload: header.payload.signature. Common claims: sub (user id), exp (expiry), iss (issuer), aud (audience).
alg: none. Pin allowed algorithms server-side.Public-key credentials backed by the device (Face ID, Touch ID, Windows Hello, hardware keys). Phishing-resistant by design and rapidly becoming the default for new consumer apps. Supported by every major browser and platform.
Long-lived shared secrets — fine for server-to-server when scoped, rotated, and stored in a secret manager. Not appropriate for end-user authentication.
| Where | Pros | Cons |
|---|---|---|
| HttpOnly cookie | Inaccessible to JS — strong against XSS. Browser auto-sends. | Needs CSRF protection (SameSite, double-submit). |
| Authorization header | Standard for APIs. No CSRF surface. | Client code must hold the token — XSS can read it. |
| localStorage | Easy. | Readable by any JS on the page. Avoid for sensitive tokens. |
| In-memory only | Disappears on tab close — minimal blast radius. | Lost on refresh; needs a refresh-token flow. |
Use argon2id, bcrypt, or scrypt. Never SHA-256 or MD5 alone.
TOTP apps, WebAuthn, push approvals. SMS only as a fallback — SIM-swappable.
Per-IP and per-account. Lockouts after N failed attempts.
Check new passwords against Have I Been Pwned's k-anonymity API.
One-time signed link; expire it. Never log the token.
Issue a new session ID after login and on privilege changes — defeats fixation.
SSO lets a user authenticate once with an IdP and access many apps. Two flavors dominate: OIDC (modern, JSON, mobile-friendly) and SAML (XML, enterprise-entrenched). Most B2B SaaS supports both — Auth0, Okta, WorkOS, and Cognito package the integration so you don't write SAML XML by hand.
"SCIM" is the companion standard for syncing user accounts and groups from the IdP into your app — without it, customers manually create users twice.
aud / iss. A token issued for service A should not unlock service B.