pub struct AuthManager<U>where
U: Authenticatable,{ /* private fields */ }Expand description
Resolves named guards — guard("api") picks one by name.
One user type per manager. An application with genuinely different user kinds (customers and staff, with different tables) wants one manager each, which is also clearer than a single registry returning different shapes.
Implementations§
Source§impl<U> AuthManager<U>where
U: Authenticatable,
impl<U> AuthManager<U>where
U: Authenticatable,
Sourcepub fn new(default: impl Into<String>) -> AuthManager<U>
pub fn new(default: impl Into<String>) -> AuthManager<U>
A manager whose default guard is default.
Sourcepub fn register(self, guard: Arc<dyn Guard<U>>) -> AuthManager<U>
pub fn register(self, guard: Arc<dyn Guard<U>>) -> AuthManager<U>
Register a guard under its own name.
Sourcepub fn default_name(&self) -> &str
pub fn default_name(&self) -> &str
The default guard’s name.
Sourcepub fn guard_names(&self) -> Vec<&str>
pub fn guard_names(&self) -> Vec<&str>
Every registered guard’s name.
Sourcepub async fn user(&self, request: &Request) -> Result<Option<U>, Error>
pub async fn user(&self, request: &Request) -> Result<Option<U>, Error>
The user behind request, via the default guard.
Sourcepub async fn user_via(
&self,
name: &str,
request: &Request,
) -> Result<Option<U>, Error>
pub async fn user_via( &self, name: &str, request: &Request, ) -> Result<Option<U>, Error>
The user behind request, via a named guard.
Trait Implementations§
Auto Trait Implementations§
impl<U> !RefUnwindSafe for AuthManager<U>
impl<U> !UnwindSafe for AuthManager<U>
impl<U> Freeze for AuthManager<U>
impl<U> Send for AuthManager<U>
impl<U> Sync for AuthManager<U>
impl<U> Unpin for AuthManager<U>
impl<U> UnsafeUnpin for AuthManager<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> 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.