pub struct CsrfMiddleware<Rng> { /* private fields */ }
Expand description

CSRF middleware to manage CSRF cookies and tokens.

Implementations

Creates a CSRF middleware with secure defaults. Namely:

  • The CSRF cookie will be prefixed with __Host-
  • SameSite is set to Strict.
  • Secure is set.
  • HttpOnly is set.
  • Path is set to /.

This represents the strictest possible configuration. Requests must be always sent over HTTPS. Users must explicitly relax these restrictions.

Creates a CSRF middleware with secure defaults and the provided Rng. Namely:

  • The CSRF cookie will be prefixed with __Host-
  • SameSite is set to Strict.
  • Secure is set.
  • HttpOnly is set.
  • Path is set to /.

This represents the strictest possible configuration. Requests must be always sent over HTTPS. Users must explicitly relax these restrictions.

Control whether we check for the token on requests.

Set a method and path to set a CSRF cookie. This should be all locations that whose response should set a cookie (via a Set-Cookie header) or those that need the CSRF token value in the response, such as for forms.

Sets the cookie name. Consider prefixing the cookie name with __Host- or __Secure- as an additional defense-in-depth measure against CSRF attacks.

Sets the SameSite attribute on the cookie.

Sets the HttpOnly attribute on the cookie.

Sets the Secure attribute on the cookie.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Responses produced by the service.

Errors produced by the service.

Errors produced while building a transform service.

The TransformService value created by this factory

The future response value.

Creates and returns a new Transform component, asynchronously

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

Compare self to key and return true if they are equal.

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

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