Skip to content

Commit 8f6c854

Browse files
committed
Include the issuer URLs in the error message when they don't match
1 parent 60f7365 commit 8f6c854

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

crates/oauth2-types/src/oidc.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,10 @@ impl ProviderMetadata {
647647
let metadata = self.insecure_verify_metadata()?;
648648

649649
if metadata.issuer() != issuer {
650-
return Err(ProviderMetadataVerificationError::IssuerUrlsDontMatch);
650+
return Err(ProviderMetadataVerificationError::IssuerUrlsDontMatch {
651+
expected: issuer.to_owned(),
652+
actual: metadata.issuer().to_owned(),
653+
});
651654
}
652655

653656
validate_url(
@@ -1064,8 +1067,13 @@ pub enum ProviderMetadataVerificationError {
10641067
UrlWithFragment(&'static str, Url),
10651068

10661069
/// The issuer URL doesn't match the one that was discovered.
1067-
#[error("issuer URLs don't match")]
1068-
IssuerUrlsDontMatch,
1070+
#[error("issuer URLs don't match: expected {expected:?}, got {actual:?}")]
1071+
IssuerUrlsDontMatch {
1072+
/// The expected issuer URL.
1073+
expected: String,
1074+
/// The issuer URL that was discovered.
1075+
actual: String,
1076+
},
10691077

10701078
/// `openid` is missing from the supported scopes.
10711079
#[error("missing openid scope")]
@@ -1314,7 +1322,7 @@ mod tests {
13141322
metadata.issuer = Some("https://example.com/".to_owned());
13151323
assert_matches!(
13161324
metadata.clone().validate(&issuer),
1317-
Err(ProviderMetadataVerificationError::IssuerUrlsDontMatch)
1325+
Err(ProviderMetadataVerificationError::IssuerUrlsDontMatch { .. })
13181326
);
13191327

13201328
// Err - Not https

0 commit comments

Comments
 (0)