Skip to content

Commit 323f455

Browse files
committed
fix: Support non-empty paths in OAuth2 Authorization Server Metadata URLs.
1 parent b88dab5 commit 323f455

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/rmcp/src/transport/auth.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ impl AuthorizationManager {
203203
pub async fn discover_metadata(&self) -> Result<AuthorizationMetadata, AuthError> {
204204
// according to the specification, the metadata should be located at "/.well-known/oauth-authorization-server"
205205
let mut discovery_url = self.base_url.clone();
206-
discovery_url.set_path("/.well-known/oauth-authorization-server");
206+
let path = discovery_url.path();
207+
let path_suffix = if path == "/" {
208+
""
209+
} else {
210+
path
211+
};
212+
discovery_url.set_path(&format!("/.well-known/oauth-authorization-server{path_suffix}"));
207213
debug!("discovery url: {:?}", discovery_url);
208214
let response = self
209215
.http_client

0 commit comments

Comments
 (0)