chore: add #[non_exhaustive] to remaining public structs (#768)
* chore: add #[non_exhaustive] to remaining public structs * chore: add #[non_exhaustive] to remaining public types * chore: enable exhaustive_structs/enums clippy lints * test: add untagged ServerResult deserialization regression tests
This commit is contained in:
parent
ee1c63c53f
commit
6a3b32d3ab
2 changed files with 430 additions and 211 deletions
|
|
@ -51,12 +51,9 @@ impl McpOAuthStore {
|
|||
let mut clients = HashMap::new();
|
||||
clients.insert(
|
||||
"mcp-client".to_string(),
|
||||
OAuthClientConfig {
|
||||
client_id: "mcp-client".to_string(),
|
||||
client_secret: Some("mcp-client-secret".to_string()),
|
||||
scopes: vec!["profile".to_string(), "email".to_string()],
|
||||
redirect_uri: "http://localhost:8080/callback".to_string(),
|
||||
},
|
||||
OAuthClientConfig::new("mcp-client", "http://localhost:8080/callback")
|
||||
.with_client_secret("mcp-client-secret")
|
||||
.with_scopes(vec!["profile".to_string(), "email".to_string()]),
|
||||
);
|
||||
|
||||
Self {
|
||||
|
|
@ -520,17 +517,16 @@ async fn oauth_authorization_server() -> impl IntoResponse {
|
|||
"response_types_supported".into(),
|
||||
Value::Array(vec![Value::String("code".into())]),
|
||||
);
|
||||
let metadata = AuthorizationMetadata {
|
||||
authorization_endpoint: format!("http://{}/oauth/authorize", BIND_ADDRESS),
|
||||
token_endpoint: format!("http://{}/oauth/token", BIND_ADDRESS),
|
||||
scopes_supported: Some(vec!["profile".to_string(), "email".to_string()]),
|
||||
registration_endpoint: Some(format!("http://{}/oauth/register", BIND_ADDRESS)),
|
||||
response_types_supported: Some(vec!["code".to_string()]),
|
||||
code_challenge_methods_supported: Some(vec!["S256".to_string()]),
|
||||
issuer: Some(BIND_ADDRESS.to_string()),
|
||||
jwks_uri: Some(format!("http://{}/oauth/jwks", BIND_ADDRESS)),
|
||||
additional_fields,
|
||||
};
|
||||
let mut metadata = AuthorizationMetadata::default();
|
||||
metadata.authorization_endpoint = format!("http://{}/oauth/authorize", BIND_ADDRESS);
|
||||
metadata.token_endpoint = format!("http://{}/oauth/token", BIND_ADDRESS);
|
||||
metadata.scopes_supported = Some(vec!["profile".to_string(), "email".to_string()]);
|
||||
metadata.registration_endpoint = Some(format!("http://{}/oauth/register", BIND_ADDRESS));
|
||||
metadata.response_types_supported = Some(vec!["code".to_string()]);
|
||||
metadata.code_challenge_methods_supported = Some(vec!["S256".to_string()]);
|
||||
metadata.issuer = Some(BIND_ADDRESS.to_string());
|
||||
metadata.jwks_uri = Some(format!("http://{}/oauth/jwks", BIND_ADDRESS));
|
||||
metadata.additional_fields = additional_fields;
|
||||
debug!("metadata: {:?}", metadata);
|
||||
(StatusCode::OK, Json(metadata))
|
||||
}
|
||||
|
|
@ -556,12 +552,8 @@ async fn oauth_register(
|
|||
let client_id = format!("client-{}", Uuid::new_v4());
|
||||
let client_secret = generate_random_string(32);
|
||||
|
||||
let client = OAuthClientConfig {
|
||||
client_id: client_id.clone(),
|
||||
client_secret: Some(client_secret.clone()),
|
||||
redirect_uri: req.redirect_uris[0].clone(),
|
||||
scopes: vec![],
|
||||
};
|
||||
let client = OAuthClientConfig::new(client_id.clone(), req.redirect_uris[0].clone())
|
||||
.with_client_secret(client_secret.clone());
|
||||
|
||||
state
|
||||
.clients
|
||||
|
|
@ -570,13 +562,9 @@ async fn oauth_register(
|
|||
.insert(client_id.clone(), client);
|
||||
|
||||
// return client information
|
||||
let response = ClientRegistrationResponse {
|
||||
client_id,
|
||||
client_secret: Some(client_secret),
|
||||
client_name: Some(req.client_name),
|
||||
redirect_uris: req.redirect_uris,
|
||||
additional_fields: HashMap::new(),
|
||||
};
|
||||
let mut response = ClientRegistrationResponse::new(client_id, req.redirect_uris);
|
||||
response.client_secret = Some(client_secret);
|
||||
response.client_name = Some(req.client_name);
|
||||
|
||||
(StatusCode::CREATED, Json(response)).into_response()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let service = StreamableHttpService::new(
|
||||
|| Ok(Counter::new()),
|
||||
LocalSessionManager::default().into(),
|
||||
StreamableHttpServerConfig {
|
||||
cancellation_token: ct.child_token(),
|
||||
..Default::default()
|
||||
},
|
||||
StreamableHttpServerConfig::default().with_cancellation_token(ct.child_token()),
|
||||
);
|
||||
|
||||
let router = axum::Router::new().nest_service("/mcp", service);
|
||||
|
|
|
|||
Loading…
Reference in a new issue