forked from 0xWheatyz/SPARC
Add rate limiting middleware to /auth/login and /auth/register endpoints #1501
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
Roadmap item: P1 Error handling and resilience
The login and register endpoints have no protection against brute-force attacks or credential-stuffing. An attacker can make unlimited attempts with no back-off.
What to do
slowapi(orfastapi-limiter/starlette-ratelimit) as a dependency.POST /auth/loginandPOST /auth/register.HTTP 429 Too Many Requestswith aRetry-Afterheader when the limit is exceeded.AUTH_RATE_LIMIT_PER_MINUTE).Acceptance criteria
POST /auth/loginis rate-limitedPOST /auth/registeris rate-limitedRetry-Afterheader[Repo Manager] This issue is already resolved. Rate limiting is implemented using
slowapiinapi.py:/auth/registeris limited to 5/minute,/auth/loginto 10/minute, with a proper 429 handler. Closing as complete.