logo
pub struct Csrf { /* private fields */ }
Available on crate feature csrf only.
Expand description

Cross-Site Request Forgery (CSRF) protection middleware.

Implementations

Create a new instance.

Defaults

The defaults for Csrf 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]

Set 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.

Set the name of the HTTP header where the middleware will look for the CSRF token.

Defaults to “x-csrf-token”.

Set the name of the query parameter where the middleware will look for the CSRF token.

Defaults to “csrf-token”.

Set the name of the form field where the middleware will look for the CSRF token.

Defaults to “csrf-token”.

Set the list of methods that will be protected by this middleware.

Defaults to [POST, PUT, PATCH, DELETE]

Trait Implementations

Formats the value using the given formatter. Read more

Handle http request.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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