Skip to content

Commit ebb6914

Browse files
committed
WIP
1 parent bc836b5 commit ebb6914

File tree

5 files changed

+78
-2
lines changed

5 files changed

+78
-2
lines changed

routing/routes/routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use SimpleSAML\Module\oidc\Controllers\ConfigurationDiscoveryController;
1616
use SimpleSAML\Module\oidc\Controllers\EndSessionController;
1717
use SimpleSAML\Module\oidc\Controllers\Federation\EntityStatementController;
18+
use SimpleSAML\Module\oidc\Controllers\Federation\SubordinateListingsController;
1819
use SimpleSAML\Module\oidc\Controllers\JwksController;
1920
use SimpleSAML\Module\oidc\Controllers\UserInfoController;
2021
use SimpleSAML\OpenID\Codebooks\HttpMethodsEnum;
@@ -96,4 +97,8 @@
9697
$routes->add(RoutesEnum::FederationFetch->name, RoutesEnum::FederationFetch->value)
9798
->controller([EntityStatementController::class, 'fetch'])
9899
->methods([HttpMethodsEnum::GET->value]);
100+
101+
$routes->add(RoutesEnum::FederationList->name, RoutesEnum::FederationList->value)
102+
->controller([SubordinateListingsController::class, 'list'])
103+
->methods([HttpMethodsEnum::GET->value]);
99104
};

src/Codebooks/RoutesEnum.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ enum RoutesEnum: string
4646

4747
case FederationConfiguration = '.well-known/openid-federation';
4848
case FederationFetch = 'federation/fetch';
49+
case FederationList = 'federation/list';
4950
}

src/Controllers/Federation/EntityStatementController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function configuration(): Response
211211

212212
public function fetch(Request $request): Response
213213
{
214-
$subject = $request->query->get(ClaimsEnum::Sub->value);
214+
$subject = $request->query->getString(ClaimsEnum::Sub->value);
215215

216216
if (empty($subject)) {
217217
return $this->routes->newJsonErrorResponse(
@@ -222,7 +222,6 @@ public function fetch(Request $request): Response
222222
}
223223

224224
/** @var non-empty-string $subject */
225-
$subject = (string)$subject;
226225

227226
$cachedSubordinateStatement = $this->federationCache?->get(
228227
null,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Module\oidc\Controllers\Federation;
6+
7+
use SimpleSAML\Module\oidc\Helpers;
8+
use SimpleSAML\Module\oidc\ModuleConfig;
9+
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
10+
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
11+
use SimpleSAML\Module\oidc\Services\LoggerService;
12+
use SimpleSAML\Module\oidc\Utils\Routes;
13+
use SimpleSAML\OpenID\Codebooks\ErrorsEnum;
14+
use SimpleSAML\OpenID\Codebooks\ParamsEnum;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\Response;
17+
18+
class SubordinateListingsController
19+
{
20+
/**
21+
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
22+
*/
23+
public function __construct(
24+
private readonly ModuleConfig $moduleConfig,
25+
private readonly ClientRepository $clientRepository,
26+
private readonly Helpers $helpers,
27+
private readonly Routes $routes,
28+
private readonly LoggerService $loggerService,
29+
) {
30+
if (!$this->moduleConfig->getFederationEnabled()) {
31+
throw OidcServerException::forbidden('federation capabilities not enabled');
32+
}
33+
}
34+
35+
public function list(Request $request): Response
36+
{
37+
// If unsupported query parameter is provided, we have to respond with an error: "If the responder does not
38+
// support this feature, it MUST use the HTTP status code 400 and the content type application/json, with
39+
// the error code unsupported_parameter."
40+
41+
// Currently, we don't support any of the mentioned params in the spec, so let's return error for any of them.
42+
$unsupportedParams = [
43+
ParamsEnum::EntityType->value,
44+
ParamsEnum::TrustMarked->value,
45+
ParamsEnum::TrustMarkId->value,
46+
ParamsEnum::Intermediate->value,
47+
];
48+
49+
$requestedParams = array_keys($request->query->all());
50+
51+
if (!empty($intersectedParams = array_intersect($unsupportedParams, $requestedParams))) {
52+
return $this->routes->newJsonErrorResponse(
53+
ErrorsEnum::UnsupportedParameter->value,
54+
'Unsupported parameter: ' . implode(', ', $intersectedParams),
55+
);
56+
}
57+
58+
dd($request->query->all());
59+
60+
61+
if ($entityTypes = $request->query->all(ParamsEnum::EntityType->value)) {
62+
}
63+
64+
return new Response();
65+
}
66+
}

src/Utils/Routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,9 @@ public function urlFederationFetch(array $parameters = []): string
193193
{
194194
return $this->getModuleUrl(RoutesEnum::FederationFetch->value, $parameters);
195195
}
196+
197+
public function urlFederationList(array $parameters = []): string
198+
{
199+
return $this->getModuleUrl(RoutesEnum::FederationList->value, $parameters);
200+
}
196201
}

0 commit comments

Comments
 (0)