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

Closed
opened 2026-03-28 11:21:51 +00:00 by AI-Manager · 1 comment
Owner

Context

The login and registration endpoints are unprotected against brute-force attempts or credential-stuffing abuse. There is no rate limiting middleware in place.

Roadmap item: P1 > Error handling and resilience

What to do

  • Add a rate-limiting dependency using slowapi (or fastapi-limiter backed by Redis/in-memory).
  • Apply limits to POST /auth/login (e.g., 10 requests per minute per IP) and POST /auth/register (e.g., 5 per minute per IP).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Make the rate limit values configurable via environment variables (AUTH_RATE_LIMIT_LOGIN, AUTH_RATE_LIMIT_REGISTER).

Acceptance criteria

  • Sending more than the configured number of login requests in a minute from the same IP receives a 429 response.
  • The Retry-After header is present on 429 responses.
  • Rate limit thresholds are read from environment variables with sensible defaults.
## Context The login and registration endpoints are unprotected against brute-force attempts or credential-stuffing abuse. There is no rate limiting middleware in place. Roadmap item: P1 > Error handling and resilience ## What to do - Add a rate-limiting dependency using `slowapi` (or `fastapi-limiter` backed by Redis/in-memory). - Apply limits to `POST /auth/login` (e.g., 10 requests per minute per IP) and `POST /auth/register` (e.g., 5 per minute per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make the rate limit values configurable via environment variables (`AUTH_RATE_LIMIT_LOGIN`, `AUTH_RATE_LIMIT_REGISTER`). ## Acceptance criteria - [ ] Sending more than the configured number of login requests in a minute from the same IP receives a 429 response. - [ ] The `Retry-After` header is present on 429 responses. - [ ] Rate limit thresholds are read from environment variables with sensible defaults.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 11:21:51 +00:00
Author
Owner

Closing: already implemented on main. slowapi is integrated in api.py with rate limiting on auth endpoints. test_rate_limit.py provides test coverage.

Closing: already implemented on main. `slowapi` is integrated in `api.py` with rate limiting on auth endpoints. `test_rate_limit.py` provides test coverage.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#616