Skip to content

Commit 8f8833f

Browse files
committed
refactor(auth): remove non-essential comments from SEP-2352 binding
1 parent 840c099 commit 8f8833f

1 file changed

Lines changed: 1 addition & 26 deletions

File tree

crates/rmcp/src/transport/auth.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ pub struct StoredCredentials {
6868
pub granted_scopes: Vec<String>,
6969
#[serde(default)]
7070
pub token_received_at: Option<u64>,
71-
/// Authorization server `issuer` these credentials are bound to (SEP-2352).
72-
/// `None` for legacy credentials that predate issuer tracking.
7371
#[serde(default)]
7472
pub issuer: Option<String>,
7573
}
@@ -90,8 +88,7 @@ impl std::fmt::Debug for StoredCredentials {
9088
}
9189

9290
impl StoredCredentials {
93-
/// Create a new `StoredCredentials` instance, unbound to any authorization
94-
/// server. Use [`StoredCredentials::with_issuer`] to record the issuer.
91+
/// Create a new `StoredCredentials` instance.
9592
pub fn new(
9693
client_id: String,
9794
token_response: Option<OAuthTokenResponse>,
@@ -107,7 +104,6 @@ impl StoredCredentials {
107104
}
108105
}
109106

110-
/// Bind these credentials to the given authorization server `issuer` (SEP-2352).
111107
pub fn with_issuer(mut self, issuer: impl Into<String>) -> Self {
112108
self.issuer = Some(issuer.into());
113109
self
@@ -1244,14 +1240,10 @@ impl AuthorizationManager {
12441240
/// to avoid races between token retrieval and the actual HTTP request.
12451241
const REFRESH_BUFFER_SECS: u64 = 30;
12461242

1247-
/// The `issuer` of the authorization server this manager is currently
1248-
/// configured against, per the discovered [`AuthorizationMetadata`].
12491243
fn current_issuer(&self) -> Option<&str> {
12501244
self.metadata.as_ref().and_then(|m| m.issuer.as_deref())
12511245
}
12521246

1253-
/// Build [`StoredCredentials`] stamped with the currently-configured
1254-
/// authorization server `issuer` (SEP-2352).
12551247
fn stored_credentials(
12561248
&self,
12571249
client_id: String,
@@ -1267,12 +1259,6 @@ impl AuthorizationManager {
12671259
}
12681260
}
12691261

1270-
/// Enforce SEP-2352 authorization-server binding: reject a token when its
1271-
/// stored issuer differs from the currently-configured issuer. Credentials
1272-
/// with no recorded issuer (legacy) or an unset active issuer pass through.
1273-
///
1274-
/// CIMD client_ids (HTTPS URLs) are portable across authorization servers,
1275-
/// so they are exempt from the binding check.
12761262
fn check_issuer_binding(&self, stored: &StoredCredentials) -> Result<(), AuthError> {
12771263
if is_https_url(&stored.client_id) {
12781264
return Ok(());
@@ -1301,9 +1287,6 @@ impl AuthorizationManager {
13011287
return Err(AuthError::AuthorizationRequired);
13021288
};
13031289

1304-
// SEP-2352: on an AS mismatch, drop the stale credentials so the next
1305-
// authorization flow re-registers with the new AS rather than reusing
1306-
// credentials that are invalid there.
13071290
if let Err(e) = self.check_issuer_binding(&stored_creds) {
13081291
self.credential_store.clear().await?;
13091292
return Err(e);
@@ -2376,8 +2359,6 @@ impl OAuthState {
23762359

23772360
*manager.current_scopes.write().await = granted_scopes.clone();
23782361

2379-
// Discover metadata before persisting so credentials are bound to
2380-
// the resolved issuer (SEP-2352).
23812362
let metadata = manager.discover_metadata().await?;
23822363
manager.metadata = Some(metadata);
23832364

@@ -4114,8 +4095,6 @@ mod tests {
41144095
);
41154096
}
41164097

4117-
// -- SEP-2352: authorization server binding --
4118-
41194098
fn metadata_with_issuer(issuer: &str) -> AuthorizationMetadata {
41204099
AuthorizationMetadata {
41214100
authorization_endpoint: format!("{issuer}/authorize"),
@@ -4151,8 +4130,6 @@ mod tests {
41514130

41524131
#[tokio::test]
41534132
async fn get_access_token_clears_stale_credentials_on_mismatch() {
4154-
// On an AS mismatch the stale credentials are dropped so the next
4155-
// authorization flow re-registers with the new AS.
41564133
let manager =
41574134
manager_with_metadata(Some(metadata_with_issuer("https://as-b.example.com"))).await;
41584135

@@ -4171,8 +4148,6 @@ mod tests {
41714148

41724149
#[tokio::test]
41734150
async fn get_access_token_allows_portable_cimd_client_id_across_servers() {
4174-
// CIMD client_ids (HTTPS URLs) are portable, so a differing issuer
4175-
// must not trigger a mismatch.
41764151
let manager =
41774152
manager_with_metadata(Some(metadata_with_issuer("https://as-b.example.com"))).await;
41784153

0 commit comments

Comments
 (0)