Add rate limiting to /auth/login and /auth/register endpoints #642

Closed
opened 2026-03-28 12:22:18 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error Handling and Resilience

/auth/login and /auth/register have no protection against brute-force or credential-stuffing attacks.

What to do

  • Add rate limiting middleware to the FastAPI app (e.g. slowapi or a custom starlette middleware)
  • Apply a sensible limit to the auth endpoints: e.g. 10 requests per minute per IP for login, 5 per minute per IP for registration
  • Return HTTP 429 with a Retry-After header when the limit is exceeded
  • Document the rate limit thresholds in config.py or as environment variables so they can be adjusted without code changes

Acceptance criteria

  • Exceeding the login rate limit returns 429
  • Exceeding the registration rate limit returns 429
  • Normal usage (under the limit) is unaffected
  • Thresholds are configurable via environment variables
## Context Roadmap item: P1 Error Handling and Resilience `/auth/login` and `/auth/register` have no protection against brute-force or credential-stuffing attacks. ## What to do - Add rate limiting middleware to the FastAPI app (e.g. `slowapi` or a custom `starlette` middleware) - Apply a sensible limit to the auth endpoints: e.g. 10 requests per minute per IP for login, 5 per minute per IP for registration - Return HTTP 429 with a `Retry-After` header when the limit is exceeded - Document the rate limit thresholds in `config.py` or as environment variables so they can be adjusted without code changes ## Acceptance criteria - Exceeding the login rate limit returns 429 - Exceeding the registration rate limit returns 429 - Normal usage (under the limit) is unaffected - Thresholds are configurable via environment variables
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 12:22:18 +00:00
Author
Owner

Closing as already implemented. SPARC/api.py uses slowapi with @limiter.limit() decorators on /auth/register (5/min) and /auth/login (10/min). A custom 429 handler returns proper error responses.

Closing as already implemented. `SPARC/api.py` uses `slowapi` with `@limiter.limit()` decorators on `/auth/register` (5/min) and `/auth/login` (10/min). A custom 429 handler returns proper error responses.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#642