Expand description
Bearer-token authentication, rate limiting, and security middlewares.
Structs§
- Auth
State - Shared authentication state holding the optional Bearer token for the MCP server.
- Rate
Limiter State - Lock-free token-bucket rate limiter using millisecond-precision timestamps for smooth refill.
Functions§
- default_
rate_ limiter - Create a rate limiter with the default capacity of 1000 requests per second.
- dns_
rebinding_ guard - Axum middleware that blocks DNS rebinding attacks.
- generate_
token - Generate a random
UUIDv4 token suitable for Bearer authentication. - origin_
guard - Axum middleware that blocks cross-origin requests from browsers.
- rate_
limit - Axum middleware that rejects requests with 429 when the token bucket is exhausted.
- require_
auth - Axum middleware that validates the
Authorization: Bearer <token>header againstAuthState. - security_
headers - Axum middleware that sets security-hardening response headers on every response.