Skip to main content

AuthClient

Struct AuthClient 

Source
pub struct AuthClient { /* private fields */ }
Expand description

Provider-neutral check-lock-check authentication and persistent token lifecycle.

Implementations§

Source§

impl AuthClient

Source

pub fn new( key: String, flow: Arc<dyn TokenProvider>, store: Arc<dyn CredentialStore>, options: AuthOptions, ) -> Self

Bind one credential identity to its acquisition provider and store.

Source

pub fn store_name(&self) -> &'static str

Return the active store’s backend identifier.

Source

pub async fn login(&self) -> Result<Token>

Acquire and persist a new credential under an exclusive refresh lock.

Source

pub async fn token(&self) -> Result<Token>

Load or refresh without starting an interactive login for a missing credential.

Source

pub async fn token_or_login(&self) -> Result<Token>

Load or refresh, permitting login when the store has no credential.

Source

pub async fn force_refresh(&self) -> Result<Token>

Renew even before the refresh window, without forcing an interactive login.

Source

pub async fn refresh_rejected_token( &self, stale_access_token: &str, ) -> Result<Token>

Refresh a rejected token unless another process already replaced it.

Source

pub async fn logout(&self) -> Result<()>

Delete only this credential while holding the store’s refresh lock.

Trait Implementations§

Source§

impl AuthSession for AuthClient

Source§

fn auth_client(&self) -> &AuthClient

Return the shared client that owns this session’s lifecycle.
Source§

fn store_name(&self) -> &'static str

Identify the active credential store.
Source§

fn token_with_login<'life0, 'async_trait>( &'life0 self, login: Option<bool>, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Resolve binding login policy: true forces login, false forbids it, None allows it.
Source§

fn login<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Explicitly acquire and persist a new credential.
Source§

fn token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load or renew a credential without initiating an interactive login.
Source§

fn token_or_login<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load or renew a credential, allowing login when none is stored.
Source§

fn force_refresh<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Renew the stored credential even when it has not reached its refresh window.
Source§

fn refresh_rejected_token<'life0, 'life1, 'async_trait>( &'life0 self, stale: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reuse another caller’s replacement or renew the rejected credential.
Source§

fn logout<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove the persisted credential under its refresh lock.

Auto Trait Implementations§

Blanket Implementations§

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> CompatExt for T

Source§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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