Skip to content

Commit 4ee2add

Browse files
authored
bugfix: Non-empty paths in OAuth2 Authorization Server Metadata URLs (#441)
* fix: support non-empty paths in OAuth2 Authorization Server Metadata URLs * fix: address formatting errors
1 parent f8a747e commit 4ee2add

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/rmcp/src/transport/auth.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ impl AuthorizationManager {
209209
pub async fn discover_metadata(&self) -> Result<AuthorizationMetadata, AuthError> {
210210
// according to the specification, the metadata should be located at "/.well-known/oauth-authorization-server"
211211
let mut discovery_url = self.base_url.clone();
212-
discovery_url.set_path("/.well-known/oauth-authorization-server");
212+
let path = discovery_url.path();
213+
let path_suffix = if path == "/" { "" } else { path };
214+
discovery_url.set_path(&format!(
215+
"/.well-known/oauth-authorization-server{path_suffix}"
216+
));
213217
debug!("discovery url: {:?}", discovery_url);
214218
let response = self
215219
.http_client

0 commit comments

Comments
 (0)