flip_api.utils.rate_limiter
Rate limiter configuration for trust-facing API endpoints.
Attributes
Functions
|
Per-trust rate-limit key for trust-facing endpoints. |
Module Contents
- flip_api.utils.rate_limiter._trust_name_key(request: fastapi.Request) str
Per-trust rate-limit key for trust-facing endpoints.
The trust-poll endpoints (
/tasks/pending,/trust/heartbeat) carry notrust_namepath param and sit behind a TLS-terminating proxy (CloudFront → ALB → flip-api), sorequest.client.hostis the proxy address — the same for every trust. Keying on it collapses each endpoint’s per-trust limit into a single global one shared by all trusts. Key on a hash of the trust API key header instead, so every trust is rate-limited independently. Fall back to thetrust_namepath param, then the client host.- Parameters:
request (Request) – The incoming FastAPI request.
- Returns:
A stable per-trust key —
trust:<hash>when the API key header is present, otherwise thetrust_namepath param or the client host.- Return type:
str
- flip_api.utils.rate_limiter.limiter