forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #1425
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?
Summary
The login and register endpoints have no protection against brute-force or abuse, creating a security and availability risk.
What to do
slowapiorfastapi-limiter)./auth/loginand/auth/register.Retry-Afterheader when the limit is exceeded.RATE_LIMIT_AUTH_PER_MINUTE).Acceptance criteria
References
Roadmap: P1 Error handling -- rate limiting on auth endpoints.
Already implemented.
SPARC/api.pyusesslowapiwithLimiter(key_func=get_remote_address). The/auth/registerendpoint has@limiter.limit("5/minute")and/auth/loginhas@limiter.limit("10/minute"). A customRateLimitExceededhandler returns 429 with aRetry-Afterheader.Closing as completed.