Skip to content

Commit 4c8f5ba

Browse files
authored
fix(oauth): do not treat empty secret as valid for public clients (#443)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
1 parent 8ae2c2b commit 4c8f5ba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/rmcp/src/transport/auth.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,14 @@ impl AuthorizationManager {
374374

375375
let config = OAuthClientConfig {
376376
client_id: reg_response.client_id,
377-
client_secret: reg_response.client_secret,
377+
// Some IdP returns a response where the field 'client_secret' is present but with empty string value.
378+
// In that case, the interpretation is that the client is a public client and does not have a secret during the
379+
// registration phase here, e.g. dynamic client registrations.
380+
//
381+
// Even though whether or not the empty string is valid is outside of the scope of Oauth2 spec,
382+
// we should treat it as no secret since otherwise we end up authenticating with a valid client_id with an empty client_secret
383+
// as a password, which is not a goal of the client secret.
384+
client_secret: reg_response.client_secret.filter(|s| !s.is_empty()),
378385
redirect_uri: redirect_uri.to_string(),
379386
scopes: vec![],
380387
};

0 commit comments

Comments
 (0)