Identity provider
Amazon Cognito
Handles sign-up, login, MFA and token issuance, so services only verify tokens.
In a monolith
Users table + session cookie
The app hashes passwords, stores sessions (memory, then Redis) and checks the session on every request.
In a distributed system
Central IdP + JWTs
An identity provider issues short-lived signed tokens (OIDC/JWT); the gateway and services verify signatures locally with cached public keys.
On AWS
Amazon Cognito
User pools (sign-up/sign-in, MFA, social/SAML federation, JWTs) and identity pools (temporary AWS credentials for clients).
- Cognito user pools$Hosted UI, JWTs, federation
- Third-party IdP (Auth0 / Okta)$$Rich features; an external dependency
- Self-built auth service$$Full control — you own the security bugs
- Reach for it when
- More than one service needs to know who the user is, or you need SSO, social login or MFA.
- What it costs you
- Revoking long-lived JWTs is hard — keep them short with refresh tokens
- Login depends on the IdP’s availability
- Migrating existing password hashes
- When it dies
- New logins fail; users holding valid tokens keep working until expiry, because verification is local.
Interview follow-ups
Sessions vs JWTs?
Sessions: server-side state, easy to revoke, needs a shared store when scaled. JWTs: stateless verification anywhere, hard to revoke — keep them short-lived.
Where do you verify tokens?
At the gateway for every request, and in services for authorization decisions (claims/scopes), using cached signing keys (JWKS).