pub struct OAuth2Provider { /* private fields */ }Expand description
OAuth 2.1 authentication provider
Implementations§
Source§impl OAuth2Provider
impl OAuth2Provider
Sourcepub fn new(
name: String,
client: Arc<OAuth2Client>,
resource_uri: String,
) -> Self
pub fn new( name: String, client: Arc<OAuth2Client>, resource_uri: String, ) -> Self
Create a new OAuth2 provider with MCP server resource URI
§Arguments
name- Provider name for identificationclient- OAuth2 client configured for the providerresource_uri- MCP server canonical URI (RFC 8707) - e.g., “https://mcp.example.com”
§MCP Requirement
The resource URI binds all tokens to the specific MCP server, preventing token misuse across service boundaries per RFC 8707.
Trait Implementations§
Source§impl AuthProvider for OAuth2Provider
impl AuthProvider for OAuth2Provider
Source§fn provider_type(&self) -> AuthProviderType
fn provider_type(&self) -> AuthProviderType
Provider type
Source§fn authenticate<'life0, 'async_trait>(
&'life0 self,
credentials: AuthCredentials,
) -> Pin<Box<dyn Future<Output = McpResult<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn authenticate<'life0, 'async_trait>(
&'life0 self,
credentials: AuthCredentials,
) -> Pin<Box<dyn Future<Output = McpResult<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Authenticate user with credentials
Source§fn validate_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = McpResult<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = McpResult<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate existing token/session
Source§fn refresh_token<'life0, 'life1, 'async_trait>(
&'life0 self,
refresh_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = McpResult<TokenInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn refresh_token<'life0, 'life1, 'async_trait>(
&'life0 self,
refresh_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = McpResult<TokenInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Refresh access token
Auto Trait Implementations§
impl Freeze for OAuth2Provider
impl !RefUnwindSafe for OAuth2Provider
impl Send for OAuth2Provider
impl Sync for OAuth2Provider
impl Unpin for OAuth2Provider
impl !UnwindSafe for OAuth2Provider
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