pub struct AuthState {
pub username: String,
pub password: String,
pub token: Arc<RwLock<Option<TokenState>>>,
pub oidc_config: Arc<RwLock<Option<OidcConfig>>>,
}Expand description
Authentication state manager
Fields§
§username: StringUsername for authentication
password: StringPassword for authentication
token: Arc<RwLock<Option<TokenState>>>Current token state
oidc_config: Arc<RwLock<Option<OidcConfig>>>OIDC configuration
Implementations§
Source§impl AuthState
impl AuthState
Sourcepub async fn get_oidc_config(&self, client: &Client) -> Result<OidcConfig>
pub async fn get_oidc_config(&self, client: &Client) -> Result<OidcConfig>
Fetch OIDC configuration from .well-known endpoint
Get authorization code by posting credentials Returns (code, code_verifier) tuple
Sourcepub async fn exchange_code_for_token(
&self,
client: &Client,
code: &str,
code_verifier: &str,
) -> Result<TokenState>
pub async fn exchange_code_for_token( &self, client: &Client, code: &str, code_verifier: &str, ) -> Result<TokenState>
Exchange authorization code for access token
Sourcepub async fn refresh_token(&self, client: &Client) -> Result<TokenState>
pub async fn refresh_token(&self, client: &Client) -> Result<TokenState>
Refresh access token using refresh token
Sourcepub async fn is_token_valid(&self) -> bool
pub async fn is_token_valid(&self) -> bool
Check if current token is valid
Sourcepub async fn needs_token_refresh(&self) -> bool
pub async fn needs_token_refresh(&self) -> bool
Check if token needs refresh
Sourcepub async fn get_valid_token(&self, client: &Client) -> Result<String>
pub async fn get_valid_token(&self, client: &Client) -> Result<String>
Get valid access token, refreshing if needed
Auto Trait Implementations§
impl Freeze for AuthState
impl !RefUnwindSafe for AuthState
impl Send for AuthState
impl Sync for AuthState
impl Unpin for AuthState
impl !UnwindSafe for AuthState
Blanket Implementations§
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