pub struct Csrf { /* private fields */ }Expand description
Session double-submit CSRF plugin.
Implementations§
Source§impl Csrf
impl Csrf
pub fn new() -> Self
pub fn session_key(self, key: impl Into<String>) -> Self
Sourcepub fn header(self, name: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>) -> Self
Primary request header name (default x-csrf-token).
Sourcepub fn auto(self, on: bool) -> Self
pub fn auto(self, on: bool) -> Self
Disable automatic checks; use CsrfExt::verify_csrf in handlers.
Sourcepub fn skip(self, path: impl Into<String>) -> Self
pub fn skip(self, path: impl Into<String>) -> Self
Skip auto-check for a path (/hook exact, or /api/* prefix).
Sourcepub fn except(self, path: impl Into<String>) -> Self
pub fn except(self, path: impl Into<String>) -> Self
Laravel-style alias for Self::skip.
Sourcepub fn only(self, path: impl Into<String>) -> Self
pub fn only(self, path: impl Into<String>) -> Self
Only auto-check these paths (exact or prefix*). Empty = all paths (minus except).
Sourcepub fn methods(self, methods: impl IntoIterator<Item = Method>) -> Self
pub fn methods(self, methods: impl IntoIterator<Item = Method>) -> Self
Restrict which HTTP methods require a token.
Default (empty set): all methods except GET, HEAD, OPTIONS, TRACE.
Set readable XSRF-TOKEN cookie on responses (default: true).
Sourcepub fn xsrf_header(self, name: impl Into<String>) -> Self
pub fn xsrf_header(self, name: impl Into<String>) -> Self
Alternate header read from the XSRF cookie (default x-xsrf-token).
Trait Implementations§
Source§impl Plugin for Csrf
impl Plugin for Csrf
Source§fn id(&self) -> &'static str
fn id(&self) -> &'static str
Stable plugin identifier used for dependency checks and
crate::App::has_plugin. Read moreSource§fn requires(&self) -> &'static [&'static str]
fn requires(&self) -> &'static [&'static str]
Required plugin ids that must be installed beforehand. Read more
Source§fn meta(&self) -> PluginMeta
fn meta(&self) -> PluginMeta
Display name, description, and declared
PluginMeta::sdk version.Auto Trait Implementations§
impl Freeze for Csrf
impl RefUnwindSafe for Csrf
impl Send for Csrf
impl Sync for Csrf
impl Unpin for Csrf
impl UnsafeUnpin for Csrf
impl UnwindSafe for Csrf
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