flip_api.utils.rate_limiter =========================== .. py:module:: flip_api.utils.rate_limiter .. autoapi-nested-parse:: Rate limiter configuration for trust-facing API endpoints. Attributes ---------- .. autoapisummary:: flip_api.utils.rate_limiter.limiter Functions --------- .. autoapisummary:: flip_api.utils.rate_limiter._trust_name_key Module Contents --------------- .. py:function:: _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 no ``trust_name`` path param and sit behind a TLS-terminating proxy (CloudFront → ALB → flip-api), so ``request.client.host`` is 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 the ``trust_name`` path param, then the client host. :param request: The incoming FastAPI request. :type request: Request :returns: A stable per-trust key — ``trust:`` when the API key header is present, otherwise the ``trust_name`` path param or the client host. :rtype: str .. py:data:: limiter