Skip to main content

AuthManager

Struct AuthManager 

Source
pub struct AuthManager<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: Authenticatable> AuthManager<U>

Source

pub fn new(default: impl Into<String>) -> Self

A manager whose default guard is default.

Source

pub fn register(self, guard: Arc<dyn Guard<U>>) -> Self

Register a guard under its own name.

Source

pub fn guard(&self, name: &str) -> Result<&Arc<dyn Guard<U>>>

The guard named name.

Source

pub fn default_guard(&self) -> Result<&Arc<dyn Guard<U>>>

The default guard.

Source

pub fn default_name(&self) -> &str

The default guard’s name.

Source

pub fn guard_names(&self) -> Vec<&str>

Every registered guard’s name.

Source

pub async fn user(&self, request: &Request) -> Result<Option<U>>

The user behind request, via the default guard.

Source

pub async fn user_via(&self, name: &str, request: &Request) -> Result<Option<U>>

The user behind request, via a named guard.

Source

pub async fn abilities(&self, request: &Request) -> Result<Abilities>

What the credential in request was issued to do.

Source

pub async fn abilities_via( &self, name: &str, request: &Request, ) -> Result<Abilities>

abilities, via a named guard.

Trait Implementations§

Source§

impl<U: Authenticatable> Debug for AuthManager<U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<U> !RefUnwindSafe for AuthManager<U>

§

impl<U> !UnwindSafe for AuthManager<U>

§

impl<U> Freeze for AuthManager<U>
where HashMap<String, Arc<dyn Guard<U>>>: Freeze,

§

impl<U> Send for AuthManager<U>
where HashMap<String, Arc<dyn Guard<U>>>: Send,

§

impl<U> Sync for AuthManager<U>
where HashMap<String, Arc<dyn Guard<U>>>: Sync,

§

impl<U> Unpin for AuthManager<U>
where HashMap<String, Arc<dyn Guard<U>>>: Unpin,

§

impl<U> UnsafeUnpin for AuthManager<U>
where HashMap<String, Arc<dyn Guard<U>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Actor for T
where T: Send + Sync + 'static,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

fn event_name() -> &'static str
where 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more