httpmcp_rust/auth/
oauth.rs1use crate::context::RequestContext;
2use crate::error::{McpError, Result};
3
4#[derive(Debug, Clone)]
6pub struct OAuthConfig {
7 pub client_id: String,
8 pub client_secret: String,
9}
10
11impl OAuthConfig {
12 pub async fn validate_token(&self, ctx: &RequestContext) -> Result<()> {
14 let token = ctx
15 .get_bearer_token()
16 .ok_or(McpError::AuthenticationRequired)?;
17
18 if token.is_empty() {
21 return Err(McpError::AuthorizationFailed("Invalid token".to_string()));
22 }
23
24 Ok(())
25 }
26}