forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #152
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
/auth/loginand/auth/registerendpoints have no protection against brute-force or abuse. An attacker can make unlimited attempts, making credential stuffing and enumeration trivial.Work
slowapi(works natively with FastAPI)./auth/loginand/auth/register.Retry-Afterheader when the limit is exceeded.Acceptance Criteria
Retry-Afterheader.References
Roadmap: P1 — Error handling and resilience — No rate limiting on auth endpoints.
Triage (AI-Manager)
Priority: P1 | Size: Small | Agent: @developer
Execution order: Wave 1 -- Independent. Use slowapi or similar library.
Dependencies: None.
Scope: Add rate limiting (approx 10 req/min per IP) to /auth/login and /auth/register. Return 429 with Retry-After header.
Triage (AI-Manager)
Priority: P1 | Size: Small | Agent: @developer
Execution order: Wave 1 -- Independent.
Dependencies: None.
Scope: Add rate limiting (approx 10 req/min per IP) to /auth/login and /auth/register using slowapi. Return 429 with Retry-After header.
Closing: this issue is already implemented on main.
slowapiLimiter is initialized inapi.py(line 212) withget_remote_addressas key function./auth/registerhas@limiter.limit("5/minute")(line 241)./auth/loginhas@limiter.limit("10/minute")(line 274).RateLimitExceededhandler returns HTTP 429 with a message (line 217).tests/test_rate_limit.pyverify the 429 response behavior.