Skip to content

Commit 83f95f4

Browse files
committed
Skip RFC 8414 issuer validation in legacy 2025-03-26 backcompat path
1 parent 0bb5fb7 commit 83f95f4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,15 @@ private async Task<AuthorizationServerMetadata> GetAuthServerMetadataAsync(Uri a
377377
// Validate the issuer in the metadata document per RFC 8414 Section 3.3:
378378
// the issuer value MUST be identical to the issuer identifier used to construct
379379
// the well-known URL.
380-
if (metadata.Issuer is not null &&
380+
// Skip validation in legacy backcompat mode (resourceUri is null) because the
381+
// authServerUri was derived from the server origin rather than from Protected
382+
// Resource Metadata, so it may not match the server's canonical issuer.
383+
// Note: resourceUri is null exclusively in the 2025-03-26 legacy path. For newer
384+
// protocol versions, ExtractProtectedResourceMetadata throws if the PRM document
385+
// omits the resource field (VerifyResourceMatch returns false for null Resource),
386+
// so we never reach this point with resourceUri == null in non-legacy flows.
387+
if (resourceUri is not null &&
388+
metadata.Issuer is not null &&
381389
!string.Equals(metadata.Issuer.OriginalString, authServerUri.OriginalString, StringComparison.Ordinal))
382390
{
383391
ThrowFailedToHandleUnauthorizedResponse(

0 commit comments

Comments
 (0)