pub struct AuthService<S, V> { /* private fields */ }Expand description
Tower service that performs authentication on incoming requests.
Created by AuthLayer. Extracts credentials from the configured HTTP
header, validates them using the provided Validate implementation,
and either forwards the request (injecting AuthInfo into request
extensions) or returns an HTTP 401 response.
§Example
ⓘ
// Requires the `http` feature
use tower::ServiceBuilder;
use tower_mcp::auth::{AuthLayer, ApiKeyValidator};
let validator = ApiKeyValidator::new(vec!["sk-test-key-123".to_string()]);
let service = ServiceBuilder::new()
.layer(AuthLayer::new(validator))
.service(inner_service);Trait Implementations§
Source§impl<S: Clone, V: Clone> Clone for AuthService<S, V>
impl<S: Clone, V: Clone> Clone for AuthService<S, V>
Source§fn clone(&self) -> AuthService<S, V>
fn clone(&self) -> AuthService<S, V>
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<S, V> Freeze for AuthService<S, V>
impl<S, V> RefUnwindSafe for AuthService<S, V>where
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<S, V> Send for AuthService<S, V>
impl<S, V> Sync for AuthService<S, V>
impl<S, V> Unpin for AuthService<S, V>
impl<S, V> UnwindSafe for AuthService<S, V>where
S: UnwindSafe,
V: UnwindSafe,
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