Skip to main content

AuthManager

Struct AuthManager 

Source
pub struct AuthManager { /* private fields */ }

Implementations§

Source§

impl AuthManager

Source

pub fn in_config_dir(config_dir: &Path) -> Result<Self>

Source

pub fn login( &self, profile_name: &str, provider: &str, token: &str, activate: bool, ) -> Result<()>

Source

pub fn paste_token( &self, profile_name: &str, provider: &str, token: &str, activate: bool, ) -> Result<()>

Source

pub fn paste_redirect( &self, profile_name: &str, provider: &str, redirect_or_code: &str, activate: bool, ) -> Result<()>

Source

pub fn store_oauth_tokens( &self, profile_name: &str, provider: &str, access_token: &str, refresh_token: Option<&str>, expires_in_secs: Option<u64>, activate: bool, ) -> Result<()>

Source

pub fn save_pending_oauth_login( &self, pending: &PendingOAuthLogin, ) -> Result<()>

Source

pub fn load_pending_oauth_login(&self) -> Result<Option<PendingOAuthLogin>>

Source

pub fn clear_pending_oauth_login(&self) -> Result<()>

Source

pub fn refresh( &self, profile_name: &str, access_token: &str, refresh_token: Option<&str>, expires_in_secs: Option<u64>, activate: bool, ) -> Result<()>

Source

pub fn refresh_for_provider( &self, provider: &str, profile_name: Option<&str>, ) -> Result<Option<RefreshResult>>

Source

pub fn logout(&self, profile_name: Option<&str>) -> Result<bool>

Source

pub fn remove_profile(&self, provider: &str, profile_name: &str) -> Result<bool>

Source

pub fn use_profile(&self, profile_name: &str) -> Result<()>

Source

pub fn list_profiles(&self) -> Result<Vec<AuthProfileSummary>>

Source

pub fn active_token_for_provider( &self, provider: &str, ) -> Result<Option<String>>

Return the stored token for the given provider, preferring the active profile, then a profile named “default”, then any matching profile.

Source

pub fn token_for_profile( &self, profile_name: &str, ) -> Result<Option<(String, String)>>

Look up a profile by name (regardless of provider kind). Returns (provider_kind, token) if found.

Source

pub fn resolve_credential( &self, profile_name: Option<&str>, current_provider: &str, ) -> Result<Option<ResolvedCredential>>

Resolve credentials from stored auth profiles.

Resolution order:

  1. If profile_name is Some, look up that profile by name.
  2. Active profile matching current_provider.
  3. Any active profile (provider may differ — caller should update config).

Returns None if no usable credential is found.

Source

pub fn status(&self) -> Result<AuthStatus>

Source

pub fn token_health(&self) -> Result<Vec<ProfileHealth>>

Return the health of all profiles (for auth status display).

Source

pub fn ensure_valid_token(&self, provider: &str) -> Result<Option<String>>

Check that the active profile for provider has a valid token. If the token is expired and has a refresh token, attempts a local refresh (extends expiry). Returns the token if valid/refreshed, or an error if the token is expired and cannot be refreshed.

This is designed to be called by the runtime before each provider call.

Source§

impl AuthManager

Source

pub fn migrate_if_needed(&self) -> Result<bool>

Migrate auth state from v1 to v2 format if needed. v1 → v2: adds refresh_token and token_expires_at_epoch_secs fields to profiles (handled by serde #[serde(default)]). The migration just bumps the version marker.

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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