Steven's Knowledge

Identity & Auth Providers

User identity, SSO, OAuth/OIDC - Auth0, Keycloak, Clerk, WorkOS, Okta. Don't build your own auth.

Identity & Auth Providers

User authentication is a problem you should almost never solve from scratch in 2026. Modern identity providers handle passwords, MFA, SSO, OAuth/OIDC, SAML, social login, magic links, passkeys — all behind an API your app calls.

This is distinct from Secret Management (machine-to-machine credentials, dynamic secrets) — identity is about end users and their organizations.

What an Identity Provider (IdP) Gives You

Without oneWith one
Build & secure your own password storageHosted, audited, breach-checked
Build MFA from scratch (TOTP / SMS / WebAuthn)One toggle
Implement OAuth flows from RFCsSDK call
Handle "Sign in with Google / Apple / GitHub"Configured in their dashboard
Build SAML for enterprise salesProvider handles it; you charge for SSO
Custom password reset flowsBuilt-in
Comply with SOC 2 / GDPR / HIPAAInherit their compliance
User impersonation for supportFirst-class feature

The compounding value: once you've integrated an IdP, adding "Sign in with X" is config, not code.

The Players

ProviderNotes
Auth0 (Okta)The pioneer; full-featured; expensive; great DX
ClerkNewer, developer-first; pre-built UI components; React/Next.js focus
WorkOS"Enterprise features for B2B SaaS" — SSO, SCIM, audit logs as products
OktaEnterprise IAM; deep workforce features; expensive
KeycloakOpen-source, self-host; Red Hat-backed
AuthentikOpen-source, self-host; modern alternative to Keycloak
StytchPasswordless-first; passkeys, magic links, OTP
Supabase Auth / Firebase AuthBundled with their BaaS; great if you're already there
AWS Cognito / Azure AD B2C / GCP Identity PlatformCloud-managed; deep integration with cloud IAM
OryOpen-source toolkit (Kratos, Hydra, Keto) — most flexible, most assembly required
LogtoOpen-source, modern, B2C and B2B

The space is crowded. Strong defaults in 2026:

  • B2C consumer app — Clerk (fast to ship, pretty UI) or Auth0 (proven, more flexible)
  • B2B SaaS that needs SSO — WorkOS (purpose-built for "enterprise checklist") or Auth0
  • Self-host — Keycloak (mature) or Authentik (modern)
  • Already on Supabase / Firebase — their bundled auth

Two Different Problems

B2CB2B
Who logs inIndividual usersUsers within organizations
Account modelFlat: one user, one identityHierarchical: org → users → roles
Auth methodsSocial, magic link, passkeys, passwordsSSO (Google Workspace, Okta), SAML, OIDC
OnboardingSelf-serveIT-driven; SCIM for user lifecycle
PricingPer-MAUPer-org, often with SSO upcharge
Common providersClerk, Auth0, Stytch, FirebaseWorkOS, Auth0, Okta

A B2B product that doesn't support SAML / SCIM cannot sell to enterprises. WorkOS exists specifically to ship that checklist quickly.

OAuth / OIDC: The Vocabulary

The standards every IdP speaks. Worth knowing the terms before you implement:

TermWhat it is
OAuth 2.0Authorization framework — "this app can act on behalf of this user"
OIDCIdentity layer on top of OAuth — adds "this is who the user is"
Authorization Code flowUser logs in at the IdP; your app gets a code; exchanges for tokens. The standard flow.
Implicit flowLegacy; tokens in URL. Don't use.
PKCEProtects Authorization Code from interception; mandatory for SPAs/mobile
Client Credentials flowMachine-to-machine; no user involved
Refresh tokenLong-lived; exchanged for new access tokens
Access tokenShort-lived; used to call APIs
ID tokenJWT proving who the user is (OIDC)
ScopeWhat the app is allowed to do (read:profile, write:orders)
JWTSelf-contained signed token; verified offline
Opaque tokenRandom string; verified via introspection endpoint

If you're hand-rolling OAuth, you're almost certainly making a mistake. Use your IdP's SDK.

Learning Path

When to Self-Host

Hosted IdPs are the right default. Self-host when:

  • Data-residency compliance forbids your data leaving a region a hosted provider doesn't cover.
  • Pricing at scale makes the math not work (~$10K-100K+ MAU territory).
  • You need deep customization no hosted provider supports.
  • Air-gapped or government-regulated environments.

Keycloak and Authentik are the open-source standards. Both are real systems with real ops — you need someone owning them.

When NOT to Use an IdP

Honest cases:

  • A static site with no users — no auth needed.
  • An internal tool used by a handful of engineers — your VPN + ssh is fine.
  • A demo / prototype — bare passwords in a .env and move on.

For anything user-facing in production: use an IdP. Rolling your own is a multi-year tax of CVEs, edge cases, and missed compliance.

The classic mistake is "we'll add SSO later." Late SSO migration is painful — you rebuild your user model around organizations, redo every signup flow, and rewrite every "lookup user by email" query. If you might ever sell to enterprises, model orgs from day one — even before you wire up SSO.

On this page