1+ /**
2+ * OAuth Metadata Discovery Scenarios
3+ *
4+ * These scenarios test different combinations of PRM and OAuth metadata locations:
5+ *
6+ * | Scenario | PRM Location | In WWW-Auth | OAuth Metadata Location |
7+ * |------------------|-------------------------------------------|-------------|------------------------------------------------|
8+ * | metadata-default | /.well-known/oauth-protected-resource/mcp | Yes | /.well-known/oauth-authorization-server |
9+ * | metadata-var1 | /.well-known/oauth-protected-resource/mcp | No | /.well-known/openid-configuration |
10+ * | metadata-var2 | /.well-known/oauth-protected-resource | No | /.well-known/oauth-authorization-server/tenant1|
11+ * | metadata-var3 | /custom/metadata/location.json | Yes | /tenant1/.well-known/openid-configuration |
12+ */
13+
114import type { Scenario , ConformanceCheck } from '../../../types.js' ;
215import { ScenarioUrls } from '../../../types.js' ;
316import { createAuthServer } from './helpers/createAuthServer.js' ;
@@ -6,10 +19,14 @@ import { ServerLifecycle } from './helpers/serverLifecycle.js';
619import { SpecReferences } from './spec-references.js' ;
720import { Request , Response } from 'express' ;
821
9- export class AuthBasicDCRScenario implements Scenario {
10- name = 'auth/basic-dcr' ;
11- description =
12- 'Tests Basic OAuth flow with DCR, PRM at path-based location, OAuth metadata at root location, and no scopes required' ;
22+ export class AuthMetadataDefaultScenario implements Scenario {
23+ name = 'auth/metadata-default' ;
24+ description = `Tests Basic OAuth metadata discovery flow.
25+
26+ **Registration:** via DCR
27+ **PRM:** at path-based location (root returns 404)
28+ **OAuth metadata:** at root oauth-authorization-server path
29+ ` ;
1330 private authServer = new ServerLifecycle ( ) ;
1431 private server = new ServerLifecycle ( ) ;
1532 private checks : ConformanceCheck [ ] = [ ] ;
@@ -92,13 +109,13 @@ export class AuthBasicDCRScenario implements Scenario {
92109 }
93110}
94111
95- export class AuthBasicMetadataVar1Scenario implements Scenario {
96- name = 'auth/basic- metadata-var1' ;
97- description = `
98- Tests Basic OAuth flow with:
99- Registration: via DCR
100- PRM: At the path-based location (not in WWW-authenticate )
101- OAuth metadata: at OpenID discovery path
112+ export class AuthMetadataVar1Scenario implements Scenario {
113+ name = 'auth/metadata-var1' ;
114+ description = `Tests Basic OAuth metadata discovery flow.
115+
116+ ** Registration:** via DCR
117+ ** PRM:** at path-based location (not in WWW-Authenticate )
118+ ** OAuth metadata:** at root openid-configuration path
102119` ;
103120 private authServer = new ServerLifecycle ( ) ;
104121 private server = new ServerLifecycle ( ) ;
@@ -118,7 +135,7 @@ OAuth metadata: at OpenID discovery path
118135 this . server . getUrl ,
119136 this . authServer . getUrl ,
120137 {
121- prmPath : '/.well-known/oauth-protected-resource' ,
138+ // Uses default path-based PRM location
122139 includePrmInWwwAuth : false
123140 }
124141 ) ;
@@ -156,10 +173,14 @@ OAuth metadata: at OpenID discovery path
156173 }
157174}
158175
159- export class AuthBasicMetadataVar2Scenario implements Scenario {
160- name = 'auth/basic-metadata-var2' ;
161- description =
162- 'Tests Basic OAuth flow with DCR, PRM at root location, OAuth metadata at path-based OAuth discovery path' ;
176+ export class AuthMetadataVar2Scenario implements Scenario {
177+ name = 'auth/metadata-var2' ;
178+ description = `Tests Basic OAuth metadata discovery flow.
179+
180+ **Registration:** via DCR
181+ **PRM:** at root location (not in WWW-Authenticate)
182+ **OAuth metadata:** at path-based oauth-authorization-server path (/tenant1)
183+ ` ;
163184 private authServer = new ServerLifecycle ( ) ;
164185 private server = new ServerLifecycle ( ) ;
165186 private checks : ConformanceCheck [ ] = [ ] ;
@@ -168,8 +189,7 @@ export class AuthBasicMetadataVar2Scenario implements Scenario {
168189 this . checks = [ ] ;
169190
170191 const authApp = createAuthServer ( this . checks , this . authServer . getUrl , {
171- metadataPath : '/tenant1/.well-known/openid-configuration' ,
172- isOpenIdConfiguration : true ,
192+ metadataPath : '/.well-known/oauth-authorization-server/tenant1' ,
173193 routePrefix : '/tenant1'
174194 } ) ;
175195
@@ -199,7 +219,8 @@ export class AuthBasicMetadataVar2Scenario implements Scenario {
199219 this . server . getUrl ,
200220 ( ) => `${ this . authServer . getUrl ( ) } /tenant1` ,
201221 {
202- prmPath : '/.well-known/oauth-protected-resource'
222+ prmPath : '/.well-known/oauth-protected-resource' ,
223+ includePrmInWwwAuth : false
203224 }
204225 ) ;
205226 await this . server . start ( app ) ;
@@ -236,10 +257,14 @@ export class AuthBasicMetadataVar2Scenario implements Scenario {
236257 }
237258}
238259
239- export class AuthBasicMetadataVar3Scenario implements Scenario {
240- name = 'auth/basic-metadata-var3' ;
241- description =
242- 'Tests Basic OAuth flow with DCR, PRM at custom location listed in WWW-Authenticate header, OAuth metadata is at nested OpenID discovery path, and no scopes required' ;
260+ export class AuthMetadataVar3Scenario implements Scenario {
261+ name = 'auth/metadata-var3' ;
262+ description = `Tests Basic OAuth metadata discovery flow.
263+
264+ **Registration:** via DCR
265+ **PRM:** at custom path (via resource_metadata in WWW-Authenticate)
266+ **OAuth metadata:** at path-based openid-configuration path (/tenant1)
267+ ` ;
243268 private authServer = new ServerLifecycle ( ) ;
244269 private server = new ServerLifecycle ( ) ;
245270 private checks : ConformanceCheck [ ] = [ ] ;
0 commit comments