forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #1380
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
Roadmap item: P1 Error handling and resilience — No rate limiting on auth endpoints
/auth/loginand/auth/registerare completely unprotected against brute-force attacks or automated abuse. An attacker can attempt unlimited password guesses or flood registration to exhaust resources.Task
slowapi(orfastapi-limiterwith Redis)./auth/loginand 5 requests/minute per IP to/auth/register(exact values should be configurable via env vars).Retry-Afterheader when limits are exceeded.RATE_LIMIT_*env vars in.env.example.Acceptance Criteria
Retry-Afterheader is included in the 429 response.Reference
See ROADMAP.md § P1 Error handling and resilience.
Resolved by PR #28 (merged). Rate limiting is applied via slowapi:
/auth/loginis limited to 10/minute and/auth/registerto 5/minute. Tests exist intests/test_rate_limit.py.