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

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

Context

The /auth/login and /auth/register endpoints have no protection against brute-force or credential-stuffing attacks. An attacker can make unlimited requests.

Work

  • Add rate limiting middleware (e.g., slowapi for FastAPI) to the application.
  • Apply a per-IP rate limit to /auth/login (e.g., 10 requests per minute) and /auth/register (e.g., 5 requests per minute).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Document the rate limit configuration via environment variables (AUTH_RATE_LIMIT_LOGIN, AUTH_RATE_LIMIT_REGISTER).

Acceptance Criteria

  • Sending more than the configured number of requests per minute to /auth/login results in HTTP 429.
  • The Retry-After header is present in the 429 response.
  • Rate limits are configurable via environment variables without code changes.
  • Existing auth tests continue to pass (mock or disable rate limiting in tests).

References

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

## Context The `/auth/login` and `/auth/register` endpoints have no protection against brute-force or credential-stuffing attacks. An attacker can make unlimited requests. ## Work - Add rate limiting middleware (e.g., `slowapi` for FastAPI) to the application. - Apply a per-IP rate limit to `/auth/login` (e.g., 10 requests per minute) and `/auth/register` (e.g., 5 requests per minute). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Document the rate limit configuration via environment variables (`AUTH_RATE_LIMIT_LOGIN`, `AUTH_RATE_LIMIT_REGISTER`). ## Acceptance Criteria - Sending more than the configured number of requests per minute to `/auth/login` results in HTTP 429. - The `Retry-After` header is present in the 429 response. - Rate limits are configurable via environment variables without code changes. - Existing auth tests continue to pass (mock or disable rate limiting in tests). ## References Roadmap: P1 — Error handling and resilience — No rate limiting on auth endpoints.
AI-Manager added the P1agent-readymedium labels 2026-03-26 16:22:28 +00:00
Author
Owner

This issue has already been resolved. Rate limiting is implemented using slowapi in SPARC/api.py: /auth/register is limited to 5/minute and /auth/login is limited to 10/minute. A custom rate_limit_handler returns 429 with a Retry-After header.

Resolved by prior work. Closing.

This issue has already been resolved. Rate limiting is implemented using `slowapi` in `SPARC/api.py`: `/auth/register` is limited to 5/minute and `/auth/login` is limited to 10/minute. A custom `rate_limit_handler` returns 429 with a `Retry-After` header. Resolved by prior work. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#121