pub struct CompositeAuthProvider { /* private fields */ }Expand description
Tries a list of AuthProviders in order, returning the first successful result.
Providers are tested with AuthProvider::accepts first; if no provider
accepts the credential type, Unauthorized is returned immediately.
If a matching provider returns Unauthorized, the next matching provider is tried.
§Examples
use mcp_kit::auth::{BearerTokenProvider, ApiKeyProvider, CompositeAuthProvider, IntoDynProvider};
let provider = CompositeAuthProvider::new(vec![
BearerTokenProvider::new(["token-abc"]).into_dyn(),
ApiKeyProvider::new(["key-xyz"]).into_dyn(),
]);Implementations§
Source§impl CompositeAuthProvider
impl CompositeAuthProvider
Sourcepub fn new(providers: Vec<DynAuthProvider>) -> Self
pub fn new(providers: Vec<DynAuthProvider>) -> Self
Create a composite from an ordered list of type-erased providers.
Trait Implementations§
Source§impl AuthProvider for CompositeAuthProvider
impl AuthProvider for CompositeAuthProvider
Source§fn authenticate<'a>(&'a self, credentials: &'a Credentials) -> AuthFuture<'a>
fn authenticate<'a>(&'a self, credentials: &'a Credentials) -> AuthFuture<'a>
Validate
credentials and return the authenticated identity, or an error.Source§fn accepts(&self, credentials: &Credentials) -> bool
fn accepts(&self, credentials: &Credentials) -> bool
Returns
true if this provider knows how to handle the given credential
variant. Used by CompositeAuthProvider to select the right delegate
without unnecessarily calling authenticate.Auto Trait Implementations§
impl Freeze for CompositeAuthProvider
impl !RefUnwindSafe for CompositeAuthProvider
impl Send for CompositeAuthProvider
impl Sync for CompositeAuthProvider
impl Unpin for CompositeAuthProvider
impl UnsafeUnpin for CompositeAuthProvider
impl !UnwindSafe for CompositeAuthProvider
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