Expand description
Defensive middleware for the /api/v1/auth/* sub-router.
Two layers, applied in this order:
-
rate_limit— per-source-IP token-bucket. Drops requests that exceed[server].auth_rate_limit_per_minutewith a 429 response. Source IP comes from the connection (after the optionalX-Forwarded-Forhandling that ConnectInfo gives us). Operators are still expected to terminate at a reverse proxy and rate-limit there too — this is defence in depth. -
strip_body_for_logs— explicit, even though the request-logger insuper::log_requestsonly logsmethod + uri + statustoday. Treat it as a hard guarantee that credentials submitted to/auth/tokennever end up in a log line, regardless of what the logger middleware grows into in future.
Structs§
- Auth
Rate Limiter - In-memory rate-limit table, sized by the number of distinct source IPs
that hit
/auth/*in the last minute. For typical CLI fleets this is small; entries older than two windows are pruned on every check.
Functions§
- rate_
limit - Per-source-IP rate limit middleware. Reads
[server].auth_rate_limit_per_minutefromServerState; whenNone, the middleware is a no-op (operators rate-limit at the proxy). - strip_
body_ for_ logs - Belt-and-braces: ensure no
/auth/*request body ever reaches a logger. The runtime cost is one logger-scopedtracingspan with the body field redacted; the body itself is forwarded to the handler untouched.