pub struct BasicAuthProvider { /* private fields */ }Expand description
Validates Authorization: Basic <base64(username:password)> credentials.
The base64 decoding is handled by the transport layer before the credentials
reach this provider; this provider receives the already-decoded username and
password via Credentials::Basic.
§Examples
use mcp_kit::auth::{BasicAuthProvider, AuthenticatedIdentity};
let provider = BasicAuthProvider::with_validator(|username, password| async move {
if username == "admin" && password == "secret" {
Ok(AuthenticatedIdentity::new(username).with_scopes(["admin"]))
} else {
Err(mcp_kit::McpError::Unauthorized("invalid credentials".into()))
}
});Implementations§
Trait Implementations§
Source§impl AuthProvider for BasicAuthProvider
impl AuthProvider for BasicAuthProvider
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 BasicAuthProvider
impl !RefUnwindSafe for BasicAuthProvider
impl Send for BasicAuthProvider
impl Sync for BasicAuthProvider
impl Unpin for BasicAuthProvider
impl UnsafeUnpin for BasicAuthProvider
impl !UnwindSafe for BasicAuthProvider
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