Authentication & Authorization
Verify who is calling and enforce what they may do, using safe password storage, sessions, tokens or API keys, OAuth 2.0 and OpenID Connect, and role- and object-level authorization.
5 objectives 6 steps about 145 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Store and verify passwords with an adaptive hash (Argon2id or bcrypt) and implement login, logout and password reset flows that resist account enumeration and brute force.
- Compare server-side sessions with signed tokens (JWT) and implement one correctly, including cookie flags, expiry, refresh rotation, revocation and signature and claim validation.
- Explain OAuth 2.0 authorization code with PKCE and OIDC; validate API access tokens for the configured token type (signature or introspection, issuer, audience, expiry and scopes), validate an ID token and its nonce against the initiating login transaction, and explain how short lifetimes and sender-constrained tokens limit replay.
- Enforce role-based and object-level authorization in one central place, and prove with tests that one user cannot read or change another user's resources.
- Issue API keys for machine clients that are generated from a secure random source, shown once, stored only as a hash with a lookup prefix, limited by scopes, and rotated with an overlap window or revoked immediately.
Lesson plan
6 steps, about 145 min · 5 of 5 lessons available so far
- Identity, Credentials and Permission Models (RBAC, ABAC, ReBAC) Concept · 20 min
- Storing Passwords So a Breach Is Not a Disaster Worked example · 20 min
- Sessions, Tokens or API Keys? Trade-offs and Pitfalls Concept · 30 min
- Delegated Login with OAuth 2.0 and OpenID Connect, and Stopping Token Replay Concept · 30 min
- Lab: Roles and Ownership Checks in FastAPI Lab · 30 min
- Check: Spot the Authorization Bug Knowledge check · 10 questions
Practise it
Add sign-up, login and logout to your API with Argon2id hashing and either server-side sessions or short-lived access tokens with rotating refresh tokens, protect routes with one central permission dependency for member and admin roles, issue a scoped, hashed API key for a reporting client and rotate it without downtime, and write tests proving user A gets 404 or 403 on user B's records. Use a test identity provider: reject an ID token offered as an API credential, reject wrong-audience access tokens, verify the OIDC nonce at login and never merge social identities solely because their emails match.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.