pub struct HttpSecurity {
pub cors_allowed_origins: Vec<String>,
pub rate_limit: Option<RateLimit>,
pub trust_forwarded_for: bool,
pub expose_docs: bool,
}Expand description
The transport’s security configuration: the knobs a deployment turns that are
not safe to hard-code. Read from the environment by the server runtime (see
seiva-server) and handed to router_with_security.
Default is the secure baseline: no cross-origin access (same-origin
only) and rate limiting on at RateLimit::default. A deployment opts
origins in and tunes (or disables) the limit explicitly.
Fields§
§cors_allowed_origins: Vec<String>The exact origins allowed to make cross-origin (CORS) requests, e.g.
https://app.example.com. Empty means same-origin only: cors_layer
returns None and no Access-Control-Allow-Origin is ever emitted.
rate_limit: Option<RateLimit>The per-client request rate limit, or None to disable rate limiting.
Some(RateLimit::default()) by default — disabling it is an explicit
choice, never the default.
trust_forwarded_for: boolWhether the rate limiter keys on the trusted X-Forwarded-For client IP
instead of the raw TCP peer. Leave false (the default) for a directly
exposed service; set it only behind a single trusted reverse proxy, or
every client collapses into the proxy’s single bucket. See
RateLimiter::trusting_forwarded_for.
expose_docs: boolWhether to serve the interactive API reference (/docs, /redoc,
/scalar) and the generated /openapi.json. true by default (the
FastAPI-style discovery that is a product feature). A deployment that does
not want to publish its full contract to anonymous callers (OWASP API9 —
improper inventory management) sets it false, and those four routes answer
404 while every module route keeps working.
Implementations§
Source§impl HttpSecurity
impl HttpSecurity
Sourcepub fn with_cors_origins<I, S>(origins: I) -> Self
pub fn with_cors_origins<I, S>(origins: I) -> Self
A configuration allowing the given origins for CORS (rate limiting left at
the default). Each origin must be a full scheme://host[:port], compared
verbatim against the request’s Origin header.