ai_agent/services/mcp/
auth.rs1use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
8pub struct AuthConfig {
9 pub enabled: bool,
10 pub auth_type: Option<String>,
11 pub token: Option<String>,
12}
13
14#[derive(Debug, Clone, Default, Serialize, Deserialize)]
16pub struct OAuthConfig {
17 pub client_id: Option<String>,
18 pub client_secret: Option<String>,
19 pub redirect_uri: Option<String>,
20 pub scopes: Vec<String>,
21}
22
23pub fn get_auth_headers(config: &AuthConfig) -> std::collections::HashMap<String, String> {
25 let mut headers = std::collections::HashMap::new();
26
27 if let Some(token) = &config.token {
28 headers.insert("Authorization".to_string(), format!("Bearer {}", token));
29 }
30
31 headers
32}
33
34pub fn is_auth_required(config: &AuthConfig) -> bool {
36 config.enabled && config.auth_type.is_some()
37}