Skip to content

Add global rate limiting middleware with Retry-After headers #11

@artugro

Description

@artugro

Problem

The current quota system only limits per-integration invocations via the broker. There is no global rate limiting at the HTTP layer, meaning:

  • No protection against burst traffic from any endpoint
  • No Retry-After headers to guide clients on backoff
  • No per-IP or per-user request rate limiting
  • Health check and public endpoints have no protection

Proposed Solution

Add a Redis-backed sliding window rate limiter as FastAPI middleware:

  • Use Redis sorted sets or token bucket algorithm
  • Return 429 Too Many Requests with Retry-After header
  • Configurable per-route or global limits via settings
  • Graceful degradation when Redis is unavailable (allow all)
  • Consider using slowapi library or building on existing Redis infrastructure

Add settings: RATE_LIMIT_ENABLED, RATE_LIMIT_REQUESTS_PER_MINUTE, RATE_LIMIT_BURST.

Files

  • New: src/core/rate_limit.py
  • src/main.py (add middleware)
  • src/core/settings.py (add settings)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions