File tree Expand file tree Collapse file tree
src/ModelContextProtocol.Core/Authentication Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments