#[non_exhaustive]pub struct CsrfConfig {
pub cookie_name: String,
pub header_name: String,
pub field_name: String,
pub ttl_secs: u64,
pub exempt_methods: Vec<String>,
}Expand description
Configuration for CSRF protection middleware.
Uses the double-submit cookie pattern: a signed HttpOnly cookie holds the token, and the client must echo the same token back via the configured header on state-changing requests.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.Name of the CSRF cookie.
header_name: StringName of the HTTP header that must carry the CSRF token on unsafe requests.
field_name: StringIntended form-field name for the CSRF token. Not currently read by the middleware — token validation is header-only. Retained for configuration compatibility.
ttl_secs: u64Cookie time-to-live in seconds.
exempt_methods: Vec<String>HTTP methods exempt from CSRF validation.
Trait Implementations§
Source§impl Clone for CsrfConfig
impl Clone for CsrfConfig
Source§fn clone(&self) -> CsrfConfig
fn clone(&self) -> CsrfConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CsrfConfig
impl Debug for CsrfConfig
Source§impl Default for CsrfConfig
impl Default for CsrfConfig
Source§impl<'de> Deserialize<'de> for CsrfConfigwhere
CsrfConfig: Default,
impl<'de> Deserialize<'de> for CsrfConfigwhere
CsrfConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CsrfConfig
impl RefUnwindSafe for CsrfConfig
impl Send for CsrfConfig
impl Sync for CsrfConfig
impl Unpin for CsrfConfig
impl UnsafeUnpin for CsrfConfig
impl UnwindSafe for CsrfConfig
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
Mutably borrows from an owned value. Read more