Files
sentio/config
mrorigo cbc6cadf6d Rate limit unauthenticated API requests by client IP
rate_limit_middleware was never wired into the router, and it keyed
only on the AuthContext extension - which no middleware ever inserted,
since authentication happens in the handler extractor. So nothing was
rate limited at all.

The router now layers three stages on authenticated routes: an IP-keyed
pre-auth limiter (120 req/min per address) that meters token guessing
and abuse of public endpoints, then auth middleware that resolves the
bearer token once and publishes the context as a request extension
(handlers reuse it instead of repeating the DB lookup), and finally the
per-tenant limiter reading that context. Health, docs, and tracking
endpoints stay outside the auth layer.

Client IPs come from the socket peer; when the peer is a configured
trusted proxy (SERVER__API_TRUSTED_PROXIES), the X-Forwarded-For origin
is used instead. A direct client cannot spoof the header past the
limiter.
2026-08-24 19:20:07 +02:00
..
2026-08-23 23:44:38 +02:00