You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(client,core): RFC 9207 iss parameter validation on authorization responses (SEP-2468)
- Add authorization_response_iss_parameter_supported to OAuthMetadataSchema
and OpenIdProviderMetadataSchema (RFC 8414 / RFC 9207)
- New exported validateAuthorizationResponseIssuer() implementing the
RFC 9207 Section 2.4 decision table with exact string comparison
- auth() accepts optional iss, validated against the recorded AS metadata
before the authorization code is sent to any token endpoint
- finishAuth(code, { iss }) optional second argument on both
StreamableHTTPClientTransport and SSEClientTransport
- Tests covering all four decision-table rows and the
error-response-mismatch case
Closes#2197
Add RFC 9207 `iss` parameter validation for authorization responses (SEP-2468). `OAuthMetadataSchema` and `OpenIdProviderMetadataSchema` now recognize `authorization_response_iss_parameter_supported`. The client exports a new `validateAuthorizationResponseIssuer()` helper, `auth()` accepts an optional `iss`, and `StreamableHTTPClientTransport.finishAuth()` / `SSEClientTransport.finishAuth()` accept an optional `{ iss }` second argument. When provided, the `iss` from the authorization response is validated against the issuer recorded in the authorization server metadata before the authorization code is sent to any token endpoint; on mismatch the response is rejected without processing any other response parameters. All additions are backwards-compatible.
'Authorization server metadata advertises authorization_response_iss_parameter_supported, but the authorization response did not include an iss parameter (RFC 9207)'
561
+
);
562
+
}
563
+
// Neither advertised nor present: validation is not possible; proceed.
564
+
return;
565
+
}
566
+
567
+
if(metadata===undefined){
568
+
thrownewError(
569
+
'Authorization response included an iss parameter, but no authorization server metadata was recorded to validate it against (RFC 9207)'
570
+
);
571
+
}
572
+
573
+
// Exact string comparison — no normalization of any kind (RFC 9207 Section 2.4).
574
+
if(iss!==metadata.issuer){
575
+
thrownewError(
576
+
`Authorization response iss parameter does not match the expected issuer: expected ${metadata.issuer}, got ${iss} (RFC 9207). The authorization response must not be processed.`
577
+
);
578
+
}
579
+
}
580
+
534
581
/**
535
582
* Orchestrates the full auth flow with a server.
536
583
*
@@ -542,6 +589,12 @@ export async function auth(
542
589
options: {
543
590
serverUrl: string|URL;
544
591
authorizationCode?: string;
592
+
/**
593
+
* The `iss` parameter received alongside the authorization code in the
594
+
* authorization response, validated per RFC 9207 against the issuer recorded
595
+
* in the authorization server metadata before the code is exchanged.
596
+
*/
597
+
iss?: string;
545
598
scope?: string;
546
599
resourceMetadataUrl?: URL;
547
600
fetchFn?: FetchLike;
@@ -603,12 +656,14 @@ async function authInternal(
603
656
{
604
657
serverUrl,
605
658
authorizationCode,
659
+
iss,
606
660
scope,
607
661
resourceMetadataUrl,
608
662
fetchFn
609
663
}: {
610
664
serverUrl: string|URL;
611
665
authorizationCode?: string;
666
+
iss?: string;
612
667
scope?: string;
613
668
resourceMetadataUrl?: URL;
614
669
fetchFn?: FetchLike;
@@ -747,6 +802,12 @@ async function authInternal(
747
802
748
803
// Exchange authorization code for tokens, or fetch tokens directly for non-interactive flows
Copy file name to clipboardExpand all lines: packages/client/src/client/sse.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -228,15 +228,21 @@ export class SSEClientTransport implements Transport {
228
228
229
229
/**
230
230
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
231
+
*
232
+
* @param authorizationCode - The authorization code from the authorization response
233
+
* @param options.iss - The `iss` parameter from the authorization response, if present.
234
+
* Validated against the issuer recorded in the authorization server metadata per RFC 9207
Copy file name to clipboardExpand all lines: packages/client/src/client/streamableHttp.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -489,15 +489,21 @@ export class StreamableHTTPClientTransport implements Transport {
489
489
490
490
/**
491
491
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
492
+
*
493
+
* @param authorizationCode - The authorization code from the authorization response
494
+
* @param options.iss - The `iss` parameter from the authorization response, if present.
495
+
* Validated against the issuer recorded in the authorization server metadata per RFC 9207
0 commit comments