pub struct MCPAuth { /* private fields */ }Expand description
MCP Authentication middleware
Implementations§
Source§impl MCPAuth
impl MCPAuth
Sourcepub fn new(
config: MCPAuthConfig,
audit_logger: Arc<AuditLogger>,
) -> Result<Self>
pub fn new( config: MCPAuthConfig, audit_logger: Arc<AuditLogger>, ) -> Result<Self>
Create a new authentication middleware
Sourcepub async fn authenticate_request(
&self,
method: &str,
params: Option<&Value>,
headers: &HashMap<String, String>,
) -> Result<Option<AuthContext>>
pub async fn authenticate_request( &self, method: &str, params: Option<&Value>, headers: &HashMap<String, String>, ) -> Result<Option<AuthContext>>
Authenticate an MCP request
Sourcepub async fn generate_token(
&self,
client_id: &str,
user_id: &str,
scopes: Vec<String>,
) -> Result<String>
pub async fn generate_token( &self, client_id: &str, user_id: &str, scopes: Vec<String>, ) -> Result<String>
Generate JWT token for a client
Sourcepub async fn revoke_token(&self, token: &str) -> Result<()>
pub async fn revoke_token(&self, token: &str) -> Result<()>
Revoke a JWT token
Sourcepub fn validate_tool_access(
&self,
context: &AuthContext,
tool_name: &str,
) -> Result<()>
pub fn validate_tool_access( &self, context: &AuthContext, tool_name: &str, ) -> Result<()>
Validate tool access permissions
Auto Trait Implementations§
impl Freeze for MCPAuth
impl !RefUnwindSafe for MCPAuth
impl Send for MCPAuth
impl Sync for MCPAuth
impl Unpin for MCPAuth
impl !UnwindSafe for MCPAuth
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more