forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #207
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?
Context
The authentication endpoints accept unlimited requests, making them vulnerable to brute-force password guessing and account enumeration. There is currently no middleware or decorator protecting them.
Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
What to do
slowapifor FastAPI)./auth/login(e.g. 10 requests per minute per IP) and/auth/register(e.g. 5 per hour per IP).Retry-Afterheader when the limit is exceeded.requirements.txt.Acceptance criteria
This issue has already been resolved in the current codebase.
api.pyusesslowapiwith@limiter.limit("5/minute")on the login endpoint and@limiter.limit("10/minute")on the register endpoint. A customrate_limit_handlerreturns user-friendly error responses.Closing as already implemented.