|
4 | 4 |
|
5 | 5 | namespace SimpleSAML\Module\oidc\Controllers\OAuth2; |
6 | 6 |
|
| 7 | +use SimpleSAML\Module\oidc\ModuleConfig; |
7 | 8 | use SimpleSAML\Module\oidc\Services\OpMetadataService; |
8 | 9 | use SimpleSAML\Module\oidc\Utils\Routes; |
| 10 | +use SimpleSAML\OpenID\Codebooks\AccessTokenTypesEnum; |
| 11 | +use SimpleSAML\OpenID\Codebooks\ClaimsEnum; |
| 12 | +use SimpleSAML\OpenID\Codebooks\ClientAuthenticationMethodsEnum; |
9 | 13 | use Symfony\Component\HttpFoundation\JsonResponse; |
10 | 14 |
|
11 | 15 | class OAuth2ServerConfigurationController |
12 | 16 | { |
13 | 17 | public function __construct( |
14 | 18 | protected readonly OpMetadataService $opMetadataService, |
15 | 19 | protected readonly Routes $routes, |
| 20 | + protected readonly ModuleConfig $moduleConfig, |
16 | 21 | ) { |
17 | 22 | } |
18 | 23 |
|
19 | 24 | public function __invoke(): JsonResponse |
20 | 25 | { |
21 | 26 | // We'll reuse OIDC configuration. |
| 27 | + $configuration = $this->opMetadataService->getMetadata(); |
| 28 | + |
| 29 | + if ( |
| 30 | + $this->moduleConfig->getApiEnabled() && |
| 31 | + $this->moduleConfig->getApiOAuth2TokenIntrospectionEndpointEnabled() |
| 32 | + ) { |
| 33 | + $configuration[ClaimsEnum::IntrospectionEndpoint->value] = $this->routes->urlApiOAuth2TokenIntrospection(); |
| 34 | + $configuration[ClaimsEnum::IntrospectionEndpointAuthMethodsSupported->value] = [ |
| 35 | + ClientAuthenticationMethodsEnum::ClientSecretBasic->value, |
| 36 | + ClientAuthenticationMethodsEnum::ClientSecretPost->value, |
| 37 | + ClientAuthenticationMethodsEnum::PrivateKeyJwt->value, |
| 38 | + AccessTokenTypesEnum::Bearer->value, |
| 39 | + ]; |
| 40 | + $configuration[ClaimsEnum::IntrospectionEndpointAuthSigningAlgValuesSupported->value] = $this->moduleConfig |
| 41 | + ->getSupportedAlgorithms() |
| 42 | + ->getSignatureAlgorithmBag() |
| 43 | + ->getAllNamesUnique(); |
| 44 | + } |
| 45 | + |
22 | 46 | return $this->routes->newJsonResponse( |
23 | | - $this->opMetadataService->getMetadata(), |
| 47 | + $configuration, |
24 | 48 | ); |
25 | 49 |
|
26 | 50 | // TODO mivanci Add ability for claim 'signed_metadata' when moving to simplesamlphp/openid, as per |
|
0 commit comments