@@ -346,7 +346,6 @@ public function testInvalidOidcTokenHandlerConfigurationMissingAlgorithm()
346346 public function testOidcTokenHandlerConfigurationWithDiscovery ()
347347 {
348348 $ container = new ContainerBuilder ();
349- $ jwkset = '{"keys":[{"kty":"EC","crv":"P-256","x":"FtgMtrsKDboRO-Zo0XC7tDJTATHVmwuf9GK409kkars","y":"rWDE0ERU2SfwGYCo1DWWdgFEbZ0MiAXLRBBOzBgs_jY","d":"4G7bRIiKih0qrFxc0dtvkHUll19tTyctoCR3eIbOrO0"},{"kty":"EC","crv":"P-256","x":"0QEAsI1wGI-dmYatdUZoWSRWggLEpyzopuhwk-YUnA4","y":"KYl-qyZ26HobuYwlQh-r0iHX61thfP82qqEku7i0woo","d":"iA_TV2zvftni_9aFAQwFO_9aypfJFCSpcCyevDvz220"}]} ' ;
350349 $ config = [
351350 'token_handler ' => [
352351 'oidc ' => [
@@ -384,10 +383,68 @@ public function testOidcTokenHandlerConfigurationWithDiscovery()
384383 'enableDiscovery ' ,
385384 [
386385 new Reference ('oidc_cache ' ),
387- (new ChildDefinition ('security.access_token_handler.oidc_discovery.http_client ' ))
386+ [
387+ (new ChildDefinition ('security.access_token_handler.oidc_discovery.http_client ' ))
388388 ->replaceArgument (0 , ['base_uri ' => 'https://www.example.com/realms/demo/ ' ]),
389+ ],
390+ 'security.access_token_handler.firewall1.oidc_configuration ' ,
391+ ],
392+ ],
393+ ];
394+ $ this ->assertEquals ($ expectedArgs , $ container ->getDefinition ('security.access_token_handler.firewall1 ' )->getArguments ());
395+ $ this ->assertEquals ($ expectedCalls , $ container ->getDefinition ('security.access_token_handler.firewall1 ' )->getMethodCalls ());
396+ }
397+
398+ public function testOidcTokenHandlerConfigurationWithMultipleDiscoveryBaseUri ()
399+ {
400+ $ container = new ContainerBuilder ();
401+ $ config = [
402+ 'token_handler ' => [
403+ 'oidc ' => [
404+ 'discovery ' => [
405+ 'base_uri ' => [
406+ 'https://www.example.com/realms/demo/ ' ,
407+ 'https://www.api.com/realms/api/ ' ,
408+ ],
409+ 'cache ' => [
410+ 'id ' => 'oidc_cache ' ,
411+ ],
412+ ],
413+ 'algorithms ' => ['RS256 ' , 'ES256 ' ],
414+ 'issuers ' => ['https://www.example.com ' ],
415+ 'audience ' => 'audience ' ,
416+ ],
417+ ],
418+ ];
419+
420+ $ factory = new AccessTokenFactory ($ this ->createTokenHandlerFactories ());
421+ $ finalizedConfig = $ this ->processConfig ($ config , $ factory );
422+
423+ $ factory ->createAuthenticator ($ container , 'firewall1 ' , $ finalizedConfig , 'userprovider ' );
424+
425+ $ this ->assertTrue ($ container ->hasDefinition ('security.authenticator.access_token.firewall1 ' ));
426+ $ this ->assertTrue ($ container ->hasDefinition ('security.access_token_handler.firewall1 ' ));
427+
428+ $ expectedArgs = [
429+ 'index_0 ' => (new ChildDefinition ('security.access_token_handler.oidc.signature ' ))
430+ ->replaceArgument (0 , ['RS256 ' , 'ES256 ' ]),
431+ 'index_1 ' => null ,
432+ 'index_2 ' => 'audience ' ,
433+ 'index_3 ' => ['https://www.example.com ' ],
434+ 'index_4 ' => 'sub ' ,
435+ ];
436+ $ expectedCalls = [
437+ [
438+ 'enableDiscovery ' ,
439+ [
440+ new Reference ('oidc_cache ' ),
441+ [
442+ (new ChildDefinition ('security.access_token_handler.oidc_discovery.http_client ' ))
443+ ->replaceArgument (0 , ['base_uri ' => 'https://www.example.com/realms/demo/ ' ]),
444+ (new ChildDefinition ('security.access_token_handler.oidc_discovery.http_client ' ))
445+ ->replaceArgument (0 , ['base_uri ' => 'https://www.api.com/realms/api/ ' ]),
446+ ],
389447 'security.access_token_handler.firewall1.oidc_configuration ' ,
390- 'security.access_token_handler.firewall1.oidc_jwk_set ' ,
391448 ],
392449 ],
393450 ];
0 commit comments