#[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.
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityConfig
impl Debug for SecurityConfig
Source§impl Default for SecurityConfig
impl Default for SecurityConfig
Source§fn default() -> SecurityConfig
fn default() -> SecurityConfig
Source§impl<'de> Deserialize<'de> for SecurityConfig
impl<'de> Deserialize<'de> for SecurityConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecurityConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecurityConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SecurityConfig
impl RefUnwindSafe for SecurityConfig
impl Send for SecurityConfig
impl Sync for SecurityConfig
impl Unpin for SecurityConfig
impl UnsafeUnpin for SecurityConfig
impl UnwindSafe for SecurityConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more