Add rate limiting middleware to /auth/login and /auth/register endpoints #1501

Closed
opened 2026-03-31 00:23:11 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error handling and resilience

The login and register endpoints have no protection against brute-force attacks or credential-stuffing. An attacker can make unlimited attempts with no back-off.

What to do

  1. Add slowapi (or fastapi-limiter / starlette-ratelimit) as a dependency.
  2. Apply a rate limit of ~10 requests per minute per IP to POST /auth/login and POST /auth/register.
  3. Return HTTP 429 Too Many Requests with a Retry-After header when the limit is exceeded.
  4. Make the rate limit configurable via env vars (e.g. AUTH_RATE_LIMIT_PER_MINUTE).
  5. Add a test that triggers the rate limit and asserts a 429 response.

Acceptance criteria

  • POST /auth/login is rate-limited
  • POST /auth/register is rate-limited
  • Exceeding the limit returns HTTP 429 with Retry-After header
  • Rate limit value is configurable via environment variable
  • Test covers the rate-limiting behaviour
## Context Roadmap item: P1 Error handling and resilience The login and register endpoints have no protection against brute-force attacks or credential-stuffing. An attacker can make unlimited attempts with no back-off. ## What to do 1. Add `slowapi` (or `fastapi-limiter` / `starlette-ratelimit`) as a dependency. 2. Apply a rate limit of ~10 requests per minute per IP to `POST /auth/login` and `POST /auth/register`. 3. Return `HTTP 429 Too Many Requests` with a `Retry-After` header when the limit is exceeded. 4. Make the rate limit configurable via env vars (e.g. `AUTH_RATE_LIMIT_PER_MINUTE`). 5. Add a test that triggers the rate limit and asserts a 429 response. ## Acceptance criteria - [ ] `POST /auth/login` is rate-limited - [ ] `POST /auth/register` is rate-limited - [ ] Exceeding the limit returns HTTP 429 with `Retry-After` header - [ ] Rate limit value is configurable via environment variable - [ ] Test covers the rate-limiting behaviour
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-31 00:23:11 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. Rate limiting is implemented using slowapi in api.py: /auth/register is limited to 5/minute, /auth/login to 10/minute, with a proper 429 handler. Closing as complete.

[Repo Manager] This issue is already resolved. Rate limiting is implemented using `slowapi` in `api.py`: `/auth/register` is limited to 5/minute, `/auth/login` to 10/minute, with a proper 429 handler. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1501