|
| 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 | +} |
0 commit comments