pub struct CsrfMiddleware { /* private fields */ }Expand description
CSRF protection middleware.
Validates Origin / Referer headers on state-changing requests
(POST, PUT, DELETE, PATCH) against the configured trusted origins
and the service’s own base URL.
Origin checking is delegated to AuthConfig::is_origin_trusted so
that all origin-validation logic lives in a single place.
Implementations§
Source§impl CsrfMiddleware
impl CsrfMiddleware
Sourcepub fn new(config: CsrfConfig, auth_config: Arc<AuthConfig>) -> Self
pub fn new(config: CsrfConfig, auth_config: Arc<AuthConfig>) -> Self
Create a new CSRF middleware.
Origin trust decisions are delegated to auth_config.
Trait Implementations§
Source§impl Middleware for CsrfMiddleware
impl Middleware for CsrfMiddleware
Source§fn before_request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before the request is dispatched to plugins. Read more
Source§fn after_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
response: AuthResponse,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
response: AuthResponse,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after a response has been produced. Read more
Auto Trait Implementations§
impl Freeze for CsrfMiddleware
impl !RefUnwindSafe for CsrfMiddleware
impl Send for CsrfMiddleware
impl Sync for CsrfMiddleware
impl Unpin for CsrfMiddleware
impl UnsafeUnpin for CsrfMiddleware
impl !UnwindSafe for CsrfMiddleware
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