pub struct OAuthHandler { /* private fields */ }Expand description
OAuth handler that works with any AuthStore implementation
Implementations§
Source§impl OAuthHandler
impl OAuthHandler
pub fn new(store: Arc<dyn ToolAuthStore>, redirect_uri: String) -> Self
pub fn with_provider_registry( store: Arc<dyn ToolAuthStore>, provider_registry: Arc<dyn ProviderRegistry>, redirect_uri: String, ) -> Self
Sourcepub async fn get_auth_url(
&self,
auth_entity: &str,
user_id: &str,
auth_config: &AuthType,
scopes: &[String],
) -> Result<String, AuthError>
pub async fn get_auth_url( &self, auth_entity: &str, user_id: &str, auth_config: &AuthType, scopes: &[String], ) -> Result<String, AuthError>
Generate authorization URL for OAuth2 flow
Sourcepub async fn handle_callback(
&self,
code: &str,
state: &str,
) -> Result<AuthSession, AuthError>
pub async fn handle_callback( &self, code: &str, state: &str, ) -> Result<AuthSession, AuthError>
Handle OAuth2 callback and exchange code for tokens
Sourcepub async fn refresh_session(
&self,
auth_entity: &str,
user_id: &str,
auth_config: &AuthType,
) -> Result<AuthSession, AuthError>
pub async fn refresh_session( &self, auth_entity: &str, user_id: &str, auth_config: &AuthType, ) -> Result<AuthSession, AuthError>
Refresh an expired session
Sourcepub async fn refresh_get_session(
&self,
auth_entity: &str,
user_id: &str,
auth_config: &AuthType,
) -> Result<Option<AuthSession>, AuthError>
pub async fn refresh_get_session( &self, auth_entity: &str, user_id: &str, auth_config: &AuthType, ) -> Result<Option<AuthSession>, AuthError>
Get session, automatically refreshing if expired
pub async fn get_session( &self, auth_entity: &str, user_id: &str, ) -> Result<Option<AuthSession>, AuthError>
pub async fn store_session( &self, auth_entity: &str, user_id: &str, session: AuthSession, ) -> Result<(), AuthError>
pub async fn remove_session( &self, auth_entity: &str, user_id: &str, ) -> Result<bool, AuthError>
pub async fn store_secret( &self, user_id: &str, auth_entity: Option<&str>, secret: AuthSecret, ) -> Result<(), AuthError>
pub async fn get_secret( &self, user_id: &str, auth_entity: Option<&str>, key: &str, ) -> Result<Option<AuthSecret>, AuthError>
pub async fn remove_secret( &self, user_id: &str, auth_entity: Option<&str>, key: &str, ) -> Result<bool, AuthError>
pub async fn store_oauth2_state( &self, state: OAuth2State, ) -> Result<(), AuthError>
pub async fn get_oauth2_state( &self, state: &str, ) -> Result<Option<OAuth2State>, AuthError>
pub async fn remove_oauth2_state(&self, state: &str) -> Result<(), AuthError>
pub async fn list_secrets( &self, user_id: &str, ) -> Result<HashMap<String, AuthSecret>, AuthError>
pub async fn list_sessions( &self, user_id: &str, ) -> Result<HashMap<String, AuthSession>, AuthError>
Trait Implementations§
Source§impl Clone for OAuthHandler
impl Clone for OAuthHandler
Source§fn clone(&self) -> OAuthHandler
fn clone(&self) -> OAuthHandler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OAuthHandler
impl !RefUnwindSafe for OAuthHandler
impl Send for OAuthHandler
impl Sync for OAuthHandler
impl Unpin for OAuthHandler
impl UnsafeUnpin for OAuthHandler
impl !UnwindSafe for OAuthHandler
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