pub struct BearerAuthLayer<V, C> { /* private fields */ }Expand description
Tower layer that validates Authorization: Bearer <token> headers.
The layer stores successful claims in request extensions as
AuthClaims<C> and
AuthOutcome<C>. Invalid or rejected requests receive
401 Unauthorized with WWW-Authenticate: Bearer.
Implementations§
Source§impl<V: 'static, C> BearerAuthLayer<V, C>
impl<V: 'static, C> BearerAuthLayer<V, C>
Sourcepub fn new(validator: V) -> Self
pub fn new(validator: V) -> Self
Create a new bearer-auth layer that rejects missing credentials.
Sourcepub const fn accept_missing(self) -> Self
pub const fn accept_missing(self) -> Self
Explicitly accept requests with no credentials.
Trait Implementations§
Source§impl<V: Clone, C: Clone> Clone for BearerAuthLayer<V, C>
impl<V: Clone, C: Clone> Clone for BearerAuthLayer<V, C>
Source§fn clone(&self) -> BearerAuthLayer<V, C>
fn clone(&self) -> BearerAuthLayer<V, C>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S, V, C> Layer<S> for BearerAuthLayer<V, C>where
V: 'static,
impl<S, V, C> Layer<S> for BearerAuthLayer<V, C>where
V: 'static,
Auto Trait Implementations§
impl<V, C> Freeze for BearerAuthLayer<V, C>
impl<V, C> RefUnwindSafe for BearerAuthLayer<V, C>where
V: RefUnwindSafe,
impl<V, C> Send for BearerAuthLayer<V, C>
impl<V, C> Sync for BearerAuthLayer<V, C>
impl<V, C> Unpin for BearerAuthLayer<V, C>
impl<V, C> UnsafeUnpin for BearerAuthLayer<V, C>
impl<V, C> UnwindSafe for BearerAuthLayer<V, C>where
V: RefUnwindSafe,
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