File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131 "psr/container" : " ^2.0" ,
3232 "psr/log" : " ^3" ,
3333 "simplesamlphp/composer-module-installer" : " ^1.3" ,
34- "simplesamlphp/openid" : " ~v0.1.1 " ,
34+ "simplesamlphp/openid" : " dev-entity-collection " ,
3535 "spomky-labs/base64url" : " ^2.0" ,
3636 "symfony/expression-language" : " ^7.4" ,
3737 "symfony/psr-http-message-bridge" : " ^7.4" ,
Original file line number Diff line number Diff line change 7777 $ routes ->add (RoutesEnum::AdminTestTrustMarkValidation->name , RoutesEnum::AdminTestTrustMarkValidation->value )
7878 ->controller ([FederationTestController::class, 'trustMarkValidation ' ])
7979 ->methods ([HttpMethodsEnum::GET ->value , HttpMethodsEnum::POST ->value ]);
80+ $ routes ->add (RoutesEnum::AdminTestFederationDiscovery->name , RoutesEnum::AdminTestFederationDiscovery->value )
81+ ->controller ([FederationTestController::class, 'federationDiscovery ' ])
82+ ->methods ([HttpMethodsEnum::GET ->value , HttpMethodsEnum::POST ->value ]);
8083 $ routes ->add (
8184 RoutesEnum::AdminTestVerifiableCredentialIssuance->name ,
8285 RoutesEnum::AdminTestVerifiableCredentialIssuance->value ,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ enum RoutesEnum: string
2828 // Testing
2929 case AdminTestTrustChainResolution = 'admin/test/trust-chain-resolution ' ;
3030 case AdminTestTrustMarkValidation = 'admin/test/trust-mark-validation ' ;
31+ case AdminTestFederationDiscovery = 'admin/test/federation-discovery ' ;
3132 case AdminTestVerifiableCredentialIssuance = 'admin/test/verifiable-credential-issuance ' ;
3233
3334
Original file line number Diff line number Diff line change @@ -169,4 +169,51 @@ public function trustMarkValidation(Request $request): Response
169169 RoutesEnum::AdminTestTrustMarkValidation->value ,
170170 );
171171 }
172+
173+
174+ /**
175+ * @throws \SimpleSAML\Error\ConfigurationError
176+ * @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
177+ * @throws \SimpleSAML\Module\oidc\Exceptions\OidcException
178+ */
179+ public function federationDiscovery (Request $ request ): Response
180+ {
181+ $ trustAnchorId = null ;
182+ $ isFormSubmitted = false ;
183+ $ entities = [];
184+
185+ if ($ request ->isMethod (Request::METHOD_POST )) {
186+ $ isFormSubmitted = true ;
187+
188+ !empty ($ trustAnchorId = $ request ->request ->getString ('trustAnchorId ' )) ||
189+ throw new OidcException ('Empty Trust Anchor ID. ' );
190+
191+ try {
192+ $ entities = $ this ->federationWithArrayLogger ->federationDiscovery ()->discoverAndFetch (
193+ trustAnchorId: $ trustAnchorId ,
194+ forceRefresh: true ,
195+ );
196+
197+ } catch (\Throwable $ exception ) {
198+ $ this ->arrayLogger ->error (sprintf (
199+ 'Error during entity discovery under Trust Anchor %s. Error was %s ' ,
200+ $ trustAnchorId ,
201+ $ exception ->getMessage (),
202+ ));
203+ }
204+ }
205+
206+ $ logMessages = $ this ->arrayLogger ->getEntries ();
207+
208+ return $ this ->templateFactory ->build (
209+ 'oidc:tests/federation-discovery.twig ' ,
210+ compact (
211+ 'trustAnchorId ' ,
212+ 'logMessages ' ,
213+ 'isFormSubmitted ' ,
214+ 'entities ' ,
215+ ),
216+ RoutesEnum::AdminTestFederationDiscovery->value ,
217+ );
218+ }
172219}
Original file line number Diff line number Diff line change @@ -142,6 +142,13 @@ protected function includeDefaultMenuItems(): void
142142 ),
143143 );
144144
145+ $ this ->oidcMenu ->addItem (
146+ $ this ->oidcMenu ->buildItem (
147+ $ this ->moduleConfig ->getModuleUrl (RoutesEnum::AdminTestFederationDiscovery->value ),
148+ Translate::noop ('Test Federation Discovery ' ),
149+ ),
150+ );
151+
145152 $ this ->oidcMenu ->addItem (
146153 $ this ->oidcMenu ->buildItem (
147154 $ this ->moduleConfig ->getModuleUrl (RoutesEnum::AdminConfigVerifiableCredential->value ),
Original file line number Diff line number Diff line change @@ -146,6 +146,11 @@ public function urlAdminTestTrustMarkValidation(array $parameters = []): string
146146 return $ this ->getModuleUrl (RoutesEnum::AdminTestTrustMarkValidation->value , $ parameters );
147147 }
148148
149+ public function urlAdminTestFederationDiscovery (array $ parameters = []): string
150+ {
151+ return $ this ->getModuleUrl (RoutesEnum::AdminTestFederationDiscovery->value , $ parameters );
152+ }
153+
149154 public function urlAdminTestVerifiableCredentialIssuance (array $ parameters = []): string
150155 {
151156 return $ this ->getModuleUrl (RoutesEnum::AdminTestVerifiableCredentialIssuance->value , $ parameters );
Original file line number Diff line number Diff line change 1+ {% set subPageTitle = ' Test Federation Discovery' | trans %}
2+
3+ {% extends " @oidc/base.twig" %}
4+
5+ {% block oidcContent %}
6+
7+ <p >
8+ {{ ' You can use the form below to test Federation Discovery under given Trust Anchor.' | trans }}
9+ {{ ' Log messages will show if any warnings or errors were raised during the process.' | trans }}
10+ </p >
11+
12+ <form method =" post"
13+ action =" {{ routes .urlAdminTestFederationDiscovery }}"
14+ class =" pure-form pure-form-stacked" >
15+
16+ <fieldset >
17+ <label for =" trustAnchorId" >{{ ' Trust Anchor ID' | trans }}</label >
18+ <input type =" text"
19+ name =" trustAnchorId"
20+ id =" trustAnchorId"
21+ class =" full-width"
22+ required =" "
23+ value =" {{ trustAnchorId | default }}"
24+ >
25+ <span class =" pure-form-message" ></span >
26+
27+ <br >
28+ <button type =" submit" class =" pure-button " >{{ (actionText | default (' Submit' ))| trans }}</button >
29+ </fieldset >
30+ </form >
31+
32+ {% if isFormSubmitted | default %}
33+ <h4 >{{ ' Log messages' | trans }}</h4 >
34+ <p >
35+ {% if logMessages | default %}
36+ <code class =" code-box code-box-content" >
37+ {{- logMessages | json_encode(constant (' JSON_PRETTY_PRINT' ) b-or constant (' JSON_UNESCAPED_SLASHES' )) -}}
38+ </code >
39+ {% else %}
40+ {{ ' Federation discovery passed (there were no warnings or errors during the process).' | trans }}
41+ {% endif %}
42+ </p >
43+
44+ <h4 >{{ ' Entities' | trans }}</h4 >
45+ {% if entities | default %}
46+ <code class =" code-box code-box-content" >
47+ {{- entities | json_encode(constant (' JSON_PRETTY_PRINT' ) b-or constant (' JSON_UNESCAPED_SLASHES' )) -}}
48+ </code >
49+ {% else %}
50+ {{ ' No entities were found during the process.' | trans }}
51+ {% endif %}
52+
53+ {% endif %}
54+
55+ {% endblock oidcContent -%}
You can’t perform that action at this time.
0 commit comments