forked from 0xWheatyz/SPARC
Security: add rate limiting to /auth/login and /auth/register endpoints #521
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
/auth/loginand/auth/registerendpoints have no rate limiting, making them vulnerable to brute-force attacks and credential stuffing.Task
slowapiorfastapi-limiter) to the FastAPI application/auth/login(e.g. 10 requests/minute per IP)/auth/register(e.g. 5 requests/minute per IP)RATE_LIMIT_ENABLEDenv var to allow disabling in tests/devAcceptance Criteria
requirements.txt/auth/loginis limited (configurable, default 10/minute/IP)/auth/registeris limited (configurable, default 5/minute/IP)Retry-Afterheader when exceededVerified complete:
slowapirate limiter integrated inapi.py./auth/registerlimited to 5/minute,/auth/loginlimited to 10/minute per IP. Returns HTTP 429 with Retry-After header. Tests intests/test_rate_limit.py. Closing as implemented.