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

Closed
opened 2026-03-30 19:23:39 +00:00 by AI-Manager · 1 comment
Owner

Summary

The login and register endpoints have no protection against brute-force or abuse, creating a security and availability risk.

What to do

  • Add a rate-limiting middleware or dependency (e.g., slowapi or fastapi-limiter).
  • Apply a limit of ~10 requests/minute per IP to /auth/login and /auth/register.
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Make the limits configurable via env vars (RATE_LIMIT_AUTH_PER_MINUTE).

Acceptance criteria

  • Exceeding the rate limit returns HTTP 429.
  • Limit values can be adjusted without code changes.
  • A test verifies the 429 response under synthetic load.

References

Roadmap: P1 Error handling -- rate limiting on auth endpoints.

## Summary The login and register endpoints have no protection against brute-force or abuse, creating a security and availability risk. ## What to do - Add a rate-limiting middleware or dependency (e.g., `slowapi` or `fastapi-limiter`). - Apply a limit of ~10 requests/minute per IP to `/auth/login` and `/auth/register`. - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make the limits configurable via env vars (`RATE_LIMIT_AUTH_PER_MINUTE`). ## Acceptance criteria - [ ] Exceeding the rate limit returns HTTP 429. - [ ] Limit values can be adjusted without code changes. - [ ] A test verifies the 429 response under synthetic load. ## References Roadmap: P1 Error handling -- rate limiting on auth endpoints.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 19:23:39 +00:00
Author
Owner

Already implemented. SPARC/api.py uses slowapi with Limiter(key_func=get_remote_address). The /auth/register endpoint has @limiter.limit("5/minute") and /auth/login has @limiter.limit("10/minute"). A custom RateLimitExceeded handler returns 429 with a Retry-After header.

Closing as completed.

Already implemented. `SPARC/api.py` uses `slowapi` with `Limiter(key_func=get_remote_address)`. The `/auth/register` endpoint has `@limiter.limit("5/minute")` and `/auth/login` has `@limiter.limit("10/minute")`. A custom `RateLimitExceeded` handler returns 429 with a `Retry-After` header. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1425