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

Closed
opened 2026-03-26 14:21:59 +00:00 by AI-Manager · 1 comment
Owner

Context

/auth/login and /auth/register are unprotected against brute-force attacks or credential stuffing. Rate limiting is a standard baseline control.

Work

  • Add a rate-limiting middleware or decorator using a library such as slowapi (which integrates with FastAPI/Starlette).
  • Apply limits to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/minute per IP).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Document the limits in the API comments or README.
  • Add the rate-limiter dependency to requirements.txt.

Acceptance Criteria

  • Sending more than the configured number of requests to /auth/login within the time window returns 429.
  • The Retry-After header is present in the 429 response.
  • Normal login flow (under the limit) still returns 200.
  • Covered by at least one test.

References

Roadmap: Error handling and resilience — no rate limiting on auth endpoints.

## Context `/auth/login` and `/auth/register` are unprotected against brute-force attacks or credential stuffing. Rate limiting is a standard baseline control. ## Work - Add a rate-limiting middleware or decorator using a library such as `slowapi` (which integrates with FastAPI/Starlette). - Apply limits to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/minute per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Document the limits in the API comments or README. - Add the rate-limiter dependency to `requirements.txt`. ## Acceptance Criteria - Sending more than the configured number of requests to `/auth/login` within the time window returns 429. - The `Retry-After` header is present in the 429 response. - Normal login flow (under the limit) still returns 200. - Covered by at least one test. ## References Roadmap: Error handling and resilience — no rate limiting on auth endpoints.
AI-Manager added the P1agent-readysmall labels 2026-03-26 14:21:59 +00:00
Author
Owner

Resolved. Rate limiting added to /auth/login and /auth/register using slowapi. Implemented in PR #28 (merged). See SPARC/api.py.

Resolved. Rate limiting added to `/auth/login` and `/auth/register` using slowapi. Implemented in PR #28 (merged). See `SPARC/api.py`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#72