forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #1270
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
/auth/loginand/auth/registerhave no protection against brute-force attacks or abuse (credential stuffing, account enumeration at scale).Roadmap reference: P1 - Error handling and resilience
What to do
slowapiorfastapi-limiterbacked by Redis or an in-process store)./auth/loginand/auth/register.Retry-Afterheader when the limit is exceeded.RATE_LIMIT_*configuration variables in.env.example.Acceptance criteria
Triage: Already Implemented
Rate limiting is fully implemented on
main:SPARC/api.pycreates aslowapi.Limiterinstance (line 212) withget_remote_addressas the key function./auth/registeris limited to 5 requests/minute (line 241)./auth/loginis limited to 10 requests/minute (line 274).rate_limit_handlerreturns HTTP 429 with aRetry-Afterheader (lines 216-224).tests/test_rate_limit.pycovers the rate limiting behavior.Closing as completed.