pub struct CsrfConfig {
pub cookie_name: String,
pub header_name: String,
pub mode: CsrfMode,
pub rotate_token: bool,
pub production: bool,
pub error_message: Option<String>,
}Expand description
Configuration for CSRF protection middleware.
Fields§
Cookie name for CSRF token (default: “csrf_token”).
header_name: StringHeader name for CSRF token (default: “x-csrf-token”).
mode: CsrfModeCSRF protection mode (default: DoubleSubmit).
rotate_token: boolWhether to rotate token on each request (default: false).
production: boolWhether in production mode (affects Secure cookie flag).
error_message: Option<String>Custom error message for CSRF failures.
Implementations§
Source§impl CsrfConfig
impl CsrfConfig
Sets the cookie name for CSRF token.
Sourcepub fn header_name(self, name: impl Into<String>) -> Self
pub fn header_name(self, name: impl Into<String>) -> Self
Sets the header name for CSRF token.
Sourcepub fn rotate_token(self, rotate: bool) -> Self
pub fn rotate_token(self, rotate: bool) -> Self
Enables token rotation on each request.
Sourcepub fn production(self, production: bool) -> Self
pub fn production(self, production: bool) -> Self
Sets production mode (affects Secure cookie flag).
Sourcepub fn error_message(self, message: impl Into<String>) -> Self
pub fn error_message(self, message: impl Into<String>) -> Self
Sets a custom error message for CSRF failures.
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
Auto Trait Implementations§
impl Freeze for CsrfConfig
impl RefUnwindSafe for CsrfConfig
impl Send for CsrfConfig
impl Sync for CsrfConfig
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).