From e32a79ab7e0307919ea32a8e3a5c317dd08efd1c Mon Sep 17 00:00:00 2001 From: Peter Nehrer Date: Mon, 15 Sep 2025 16:48:38 -0600 Subject: [PATCH 1/2] fix: support non-empty paths in OAuth2 Authorization Server Metadata URLs --- crates/rmcp/src/transport/auth.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/rmcp/src/transport/auth.rs b/crates/rmcp/src/transport/auth.rs index 2f77f352..801bcf7a 100644 --- a/crates/rmcp/src/transport/auth.rs +++ b/crates/rmcp/src/transport/auth.rs @@ -203,7 +203,13 @@ impl AuthorizationManager { pub async fn discover_metadata(&self) -> Result { // according to the specification, the metadata should be located at "/.well-known/oauth-authorization-server" let mut discovery_url = self.base_url.clone(); - discovery_url.set_path("/.well-known/oauth-authorization-server"); + let path = discovery_url.path(); + let path_suffix = if path == "/" { + "" + } else { + path + }; + discovery_url.set_path(&format!("/.well-known/oauth-authorization-server{path_suffix}")); debug!("discovery url: {:?}", discovery_url); let response = self .http_client From 37f394a6e05671c3a819afcd369846fe039cfc17 Mon Sep 17 00:00:00 2001 From: Peter Nehrer Date: Tue, 16 Sep 2025 06:39:11 -0600 Subject: [PATCH 2/2] fix: address formatting errors --- crates/rmcp/src/transport/auth.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/rmcp/src/transport/auth.rs b/crates/rmcp/src/transport/auth.rs index 801bcf7a..dee2b655 100644 --- a/crates/rmcp/src/transport/auth.rs +++ b/crates/rmcp/src/transport/auth.rs @@ -204,12 +204,10 @@ impl AuthorizationManager { // according to the specification, the metadata should be located at "/.well-known/oauth-authorization-server" let mut discovery_url = self.base_url.clone(); let path = discovery_url.path(); - let path_suffix = if path == "/" { - "" - } else { - path - }; - discovery_url.set_path(&format!("/.well-known/oauth-authorization-server{path_suffix}")); + let path_suffix = if path == "/" { "" } else { path }; + discovery_url.set_path(&format!( + "/.well-known/oauth-authorization-server{path_suffix}" + )); debug!("discovery url: {:?}", discovery_url); let response = self .http_client