Rate limit all routes with a global default - #31
Merged
Conversation
Auth endpoints kept their strict per-path limits but every other route was unlimited. Apply a 300/min per-client-IP default to all non-exempt routes through the existing in-house middleware (immune to the FastAPI >=0.137 / slowapi issue #281 SlowAPIMiddleware regression), exempting the infrastructure paths probes and docs rely on. The limit is consumed regardless of auth outcome, so unauthenticated traffic is capped too. Add canary and exemption tests plus a limiter-reset fixture so request counts don't leak across tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the observation in #27: non-auth routes had no rate limiting at all. Adds a 300/min per-client-IP default to every non-exempt route via the existing in-house middleware (the immune pattern — not slowapi's SlowAPIMiddleware path that FastAPI ≥0.137 breaks), with
/,/health,/docs,/openapi.json, and/.well-known/security.txtexempt. Auth endpoints keep their stricter per-path limits and don't double-consume the default bucket. Canary + exemption tests included; 124/124 green.