← All drillsGuard Your API: Authentication and Rate Limiting
What you'll be able to do- ✓Explain authentication and authorisation, and choose between 401, 403, 404 and 429
- ✓Store API keys and passwords so that a leaked database does not leak them
- ✓Build a login endpoint with a slow, salted password hash and signed tokens
- ✓Explain what a JWT protects and what it does not, and reject forged, edited, expired and unsigned tokens
- ✓Write FastAPI dependencies that check identity, role and ownership
- ✓Find and fix broken object-level authorisation, the most common API vulnerability
- ✓Build and compare fixed-window, sliding-window and token-bucket rate limiters
- ✓Add per-caller limits and a strict login limit, answering 429 with Retry-After
- ✓Attack your own service, and lock every defence in with automatic tests
Take an open API and make it safe to expose: prove who is calling, decide what each caller may do, limit how often they may ask, keep the secrets out of the code and the logs, and show with tests that every defence holds.
⌁ Every public API needs these layers: sign-in, permissions, and limits. Identity providers, API gateways and payment platforms all implement the same ideas you build here by hand.
Start this internshipCreate an account to unlock the 6 sections, the workbench, and askThili.
BeginSections
1. Guard Your API: Authentication and Rate Limiting
🔒 locked2. Lesson 1 - Who Is Asking?
🔒 locked3. Lesson 2 - Passwords and Tokens
🔒 locked4. Lesson 3 - Who May Do What?
🔒 locked5. Lesson 4 - Stop the Flood
🔒 locked6. Lesson 5 - Attack Your Own Service
🔒 lockedDig deeper
🔗OWASP API Security Top 10
docs🔗OWASP Password Storage Cheat Sheet
docs🔗RFC 7519: JSON Web Token (JWT)
docs🔗RFC 6750: Bearer token usage
docs🔗RFC 6585: 429 Too Many Requests
docs🔗RFC 9110: HTTP semantics (status codes)
docs🔗FastAPI: security tutorial
docs🔗PyJWT documentation
docs🔗Python hashlib (scrypt and password hashing)
docs🔗Python secrets (random values for secrets)
docs