Struct salvo_extra::csrf::CsrfHandler [−][src]
pub struct CsrfHandler { /* fields omitted */ }
Expand description
Cross-Site Request Forgery (CSRF) protection middleware.
Implementations
Create a new instance.
Defaults
The defaults for CsrfHandler are:
- cookie path:
/
- cookie name:
salvo.extra.csrf
- cookie domain: None
- ttl: 24 hours
- header name:
x-csrf-token
- query param:
csrf-token
- form field:
csrf-token
- protected methods:
[POST, PUT, PATCH, DELETE]
Sets the protection ttl. This will be used for both the cookie expiry and the time window over which CSRF tokens are considered valid.
The default for this value is one day.
Sets the name of the HTTP header where the middleware will look for the CSRF token.
Defaults to “x-csrf-token”.
Sets the name of the query parameter where the middleware will look for the CSRF token.
Defaults to “csrf-token”.
Sets the name of the form field where the middleware will look for the CSRF token.
Defaults to “csrf-token”.
Sets the list of methods that will be protected by this middleware
Defaults to [POST, PUT, PATCH, DELETE]
Trait Implementations
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Handle http request.
Auto Trait Implementations
impl RefUnwindSafe for CsrfHandler
impl Send for CsrfHandler
impl Sync for CsrfHandler
impl Unpin for CsrfHandler
impl UnwindSafe for CsrfHandler
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more