Security: add rate limiting to /auth/login and /auth/register endpoints #521

Closed
opened 2026-03-28 01:32:00 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error handling and resilience

The /auth/login and /auth/register endpoints have no rate limiting, making them vulnerable to brute-force attacks and credential stuffing.

Task

  • Add rate limiting middleware (e.g. slowapi or fastapi-limiter) to the FastAPI application
  • Apply a limit to /auth/login (e.g. 10 requests/minute per IP)
  • Apply a limit to /auth/register (e.g. 5 requests/minute per IP)
  • Return HTTP 429 with a clear message when limits are exceeded
  • Add RATE_LIMIT_ENABLED env var to allow disabling in tests/dev

Acceptance Criteria

  • Rate limiter dependency is added to requirements.txt
  • /auth/login is limited (configurable, default 10/minute/IP)
  • /auth/register is limited (configurable, default 5/minute/IP)
  • HTTP 429 is returned with Retry-After header when exceeded
  • Rate limiting can be disabled via env var for test environments
## Context Roadmap item: P1 Error handling and resilience The `/auth/login` and `/auth/register` endpoints have no rate limiting, making them vulnerable to brute-force attacks and credential stuffing. ## Task - Add rate limiting middleware (e.g. `slowapi` or `fastapi-limiter`) to the FastAPI application - Apply a limit to `/auth/login` (e.g. 10 requests/minute per IP) - Apply a limit to `/auth/register` (e.g. 5 requests/minute per IP) - Return HTTP 429 with a clear message when limits are exceeded - Add `RATE_LIMIT_ENABLED` env var to allow disabling in tests/dev ## Acceptance Criteria - [ ] Rate limiter dependency is added to `requirements.txt` - [ ] `/auth/login` is limited (configurable, default 10/minute/IP) - [ ] `/auth/register` is limited (configurable, default 5/minute/IP) - [ ] HTTP 429 is returned with `Retry-After` header when exceeded - [ ] Rate limiting can be disabled via env var for test environments
AI-Manager added the P1agent-readysmall labels 2026-03-28 01:32:00 +00:00
Author
Owner

Verified complete: slowapi rate limiter integrated in api.py. /auth/register limited to 5/minute, /auth/login limited to 10/minute per IP. Returns HTTP 429 with Retry-After header. Tests in tests/test_rate_limit.py. Closing as implemented.

Verified complete: `slowapi` rate limiter integrated in `api.py`. `/auth/register` limited to 5/minute, `/auth/login` limited to 10/minute per IP. Returns HTTP 429 with Retry-After header. Tests in `tests/test_rate_limit.py`. Closing as implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#521