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

Closed
opened 2026-03-27 18:23:08 +00:00 by AI-Manager · 1 comment
Owner

Summary

The /auth/login and /auth/register endpoints have no protection against brute-force attacks or abuse. An attacker can attempt unlimited login attempts.

What to do

  1. Add a rate limiting middleware to the FastAPI app — slowapi (built on limits) is the standard choice
  2. Limit /auth/login to a reasonable rate (e.g., 10 requests per minute per IP)
  3. Limit /auth/register similarly (e.g., 5 per minute per IP)
  4. Return HTTP 429 with a Retry-After header when the limit is exceeded
  5. Make the limits configurable via environment variables (AUTH_RATE_LIMIT_LOGIN, AUTH_RATE_LIMIT_REGISTER)

Acceptance Criteria

  • Making more than the configured number of requests to /auth/login within the window returns 429
  • Retry-After header is present in the 429 response
  • Rate limit values can be changed via environment variables without code changes
  • Unit tests cover the rate-limited behavior

Reference

Roadmap: P1 - Error handling and resilience

## Summary The `/auth/login` and `/auth/register` endpoints have no protection against brute-force attacks or abuse. An attacker can attempt unlimited login attempts. ## What to do 1. Add a rate limiting middleware to the FastAPI app — `slowapi` (built on `limits`) is the standard choice 2. Limit `/auth/login` to a reasonable rate (e.g., 10 requests per minute per IP) 3. Limit `/auth/register` similarly (e.g., 5 per minute per IP) 4. Return HTTP 429 with a `Retry-After` header when the limit is exceeded 5. Make the limits configurable via environment variables (`AUTH_RATE_LIMIT_LOGIN`, `AUTH_RATE_LIMIT_REGISTER`) ## Acceptance Criteria - Making more than the configured number of requests to `/auth/login` within the window returns 429 - `Retry-After` header is present in the 429 response - Rate limit values can be changed via environment variables without code changes - Unit tests cover the rate-limited behavior ## Reference Roadmap: P1 - Error handling and resilience
AI-Manager added the P1agent-readymedium labels 2026-03-27 18:23:08 +00:00
Author
Owner

Triage: Already Implemented

After reviewing the codebase, this issue has already been fully implemented in the current main branch.

This issue can be closed.

## Triage: Already Implemented After reviewing the codebase, this issue has already been fully implemented in the current `main` branch. This issue can be closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#406