pub struct Authenticate<U: Authenticatable> { /* private fields */ }Expand description
Rejects unauthenticated requests, and attaches the user to authenticated ones.
Implementations§
Source§impl<U: Authenticatable> Authenticate<U>
impl<U: Authenticatable> Authenticate<U>
Sourcepub fn new(auth: Arc<AuthManager<U>>) -> Self
pub fn new(auth: Arc<AuthManager<U>>) -> Self
Authenticate with the manager’s default guard.
Sourcepub fn with_guard(auth: Arc<AuthManager<U>>, guard: impl Into<String>) -> Self
pub fn with_guard(auth: Arc<AuthManager<U>>, guard: impl Into<String>) -> Self
Authenticate with a named guard.
Sourcepub fn resolved() -> MiddlewareStack
pub fn resolved() -> MiddlewareStack
A stack that builds this middleware from the container.
Routes are declared before the container is populated, so the
AuthManager cannot be handed over at declaration time. This defers the
resolve to when the router compiles:
ⓘ
router.get("/me", me).middleware(Authenticate::<User>::resolved());The auth middleware, attached by value. The user type is
named explicitly, which is the thing a string alias could never say.
Sourcepub fn resolved_with_guard(guard: impl Into<String>) -> MiddlewareStack
pub fn resolved_with_guard(guard: impl Into<String>) -> MiddlewareStack
resolved with a named guard — ->middleware('auth:api').
Trait Implementations§
Source§impl<U: Authenticatable> Middleware for Authenticate<U>
impl<U: Authenticatable> Middleware for Authenticate<U>
Auto Trait Implementations§
impl<U> !RefUnwindSafe for Authenticate<U>
impl<U> !UnwindSafe for Authenticate<U>
impl<U> Freeze for Authenticate<U>
impl<U> Send for Authenticate<U>
impl<U> Sync for Authenticate<U>
impl<U> Unpin for Authenticate<U>
impl<U> UnsafeUnpin for Authenticate<U>
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> ConcreteMiddleware for Twhere
T: Middleware,
impl<T> ConcreteMiddleware for Twhere
T: Middleware,
Source§fn concrete_type_id(&self) -> TypeId
fn concrete_type_id(&self) -> TypeId
The
TypeId of the implementing type.Source§fn concrete_type_name(&self) -> &'static str
fn concrete_type_name(&self) -> &'static str
Its fully-qualified type name.
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<M> IntoMiddlewareStack for Mwhere
M: Middleware,
impl<M> IntoMiddlewareStack for Mwhere
M: Middleware,
Source§fn into_middleware_stack(self) -> MiddlewareStack
fn into_middleware_stack(self) -> MiddlewareStack
Convert into a stack.