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

Closed
opened 2026-03-30 20:24:44 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 Error handling and resilience

Problem

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

What to do

  1. Add slowapi (or fastapi-limiter) as a dependency.
  2. Apply a rate limit of approximately 10 requests/minute per IP to /auth/login.
  3. Apply a rate limit of approximately 5 requests/minute per IP to /auth/register.
  4. Return HTTP 429 with a Retry-After header when the limit is exceeded.
  5. Document the env variables controlling the limits if made configurable.

Acceptance criteria

  • Exceeding the login rate limit returns HTTP 429.
  • Normal login within the limit succeeds as before.
  • Rate limits are applied per client IP.
  • A test verifies the 429 response is returned after the threshold is hit.
## Context Roadmap item: P1 Error handling and resilience ## Problem `/auth/login` and `/auth/register` have no protection against brute-force attacks or credential-stuffing abuse. ## What to do 1. Add `slowapi` (or `fastapi-limiter`) as a dependency. 2. Apply a rate limit of approximately 10 requests/minute per IP to `/auth/login`. 3. Apply a rate limit of approximately 5 requests/minute per IP to `/auth/register`. 4. Return HTTP 429 with a `Retry-After` header when the limit is exceeded. 5. Document the env variables controlling the limits if made configurable. ## Acceptance criteria - Exceeding the login rate limit returns HTTP 429. - Normal login within the limit succeeds as before. - Rate limits are applied per client IP. - A test verifies the 429 response is returned after the threshold is hit.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 20:24:44 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 21:03:10 +00:00
Author
Owner

[Triage] P1 security issue (rate limiting). Assigned to @AI-Engineer. Dispatching to @developer agent for implementation.

[Triage] P1 security issue (rate limiting). Assigned to @AI-Engineer. Dispatching to @developer agent for implementation.
Author
Owner

[Verification] All acceptance criteria met. Verified complete. slowapi rate limiter in api.py with 10/minute on /auth/login and 5/minute on /auth/register. Returns HTTP 429 with Retry-After header. Tests in tests/test_rate_limit.py verify threshold behavior. Closing as implemented.

[Verification] All acceptance criteria met. Verified complete. `slowapi` rate limiter in `api.py` with `10/minute` on `/auth/login` and `5/minute` on `/auth/register`. Returns HTTP 429 with `Retry-After` header. Tests in `tests/test_rate_limit.py` verify threshold behavior. 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#1449