#[non_exhaustive]pub struct SecurityConfig {
pub csrf_same_site: String,
pub cors_allow_origins: Vec<String>,
pub cors_allow_credentials: bool,
pub csp: String,
pub coep: String,
pub user_agent_blocklist: Vec<String>,
pub enable_pii_masking: bool,
pub csrf_signed_webhook_paths: Vec<String>,
}Expand description
Configuration options for application security layers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.csrf_same_site: StringSameSite policy for the CSRF cookie (“Lax”, “Strict”, or “None”).
cors_allow_origins: Vec<String>List of allowed origins for Cross-Origin Resource Sharing (CORS).
cors_allow_credentials: boolAllow browser credentials only for the exact configured CORS origins.
csp: StringContent-Security-Policy (CSP) header value.
coep: StringCross-Origin-Embedder-Policy value. The strict default is require-corp;
applications that deliberately embed reviewed credentialless cross-origin
media can opt into credentialless, while unsafe-none must be an
explicit application-level decision.
user_agent_blocklist: Vec<String>Case-insensitive User-Agent substrings to block in the WAF middleware. Defaults cover selected crawlers, not general HTTP clients or health probes. This forgeable header is a traffic preference, never authentication.
enable_pii_masking: boolEnable global automatic PII masking middleware on all textual responses (heavy performance cost).
csrf_signed_webhook_paths: Vec<String>Exact POST paths that are exempt from browser CSRF tokens because a mandatory signed webhook middleware authenticates them. Wildcards and route parameters are rejected.
Implementations§
Source§impl SecurityConfig
impl SecurityConfig
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Validates browser security policy and exact-path CSRF webhook exemptions.