Skip to content

Commit 121137b

Browse files
committed
Include introspection endpoint in OAuth2 metadata
1 parent 313d691 commit 121137b

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/Controllers/OAuth2/OAuth2ServerConfigurationController.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,47 @@
44

55
namespace SimpleSAML\Module\oidc\Controllers\OAuth2;
66

7+
use SimpleSAML\Module\oidc\ModuleConfig;
78
use SimpleSAML\Module\oidc\Services\OpMetadataService;
89
use SimpleSAML\Module\oidc\Utils\Routes;
10+
use SimpleSAML\OpenID\Codebooks\AccessTokenTypesEnum;
11+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
12+
use SimpleSAML\OpenID\Codebooks\ClientAuthenticationMethodsEnum;
913
use Symfony\Component\HttpFoundation\JsonResponse;
1014

1115
class OAuth2ServerConfigurationController
1216
{
1317
public function __construct(
1418
protected readonly OpMetadataService $opMetadataService,
1519
protected readonly Routes $routes,
20+
protected readonly ModuleConfig $moduleConfig,
1621
) {
1722
}
1823

1924
public function __invoke(): JsonResponse
2025
{
2126
// 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+
2246
return $this->routes->newJsonResponse(
23-
$this->opMetadataService->getMetadata(),
47+
$configuration,
2448
);
2549

2650
// TODO mivanci Add ability for claim 'signed_metadata' when moving to simplesamlphp/openid, as per

src/Utils/Routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,9 @@ public function urlApiVciCredentialOffer(array $parameters = []): string
244244
{
245245
return $this->getModuleUrl(RoutesEnum::ApiVciCredentialOffer->value, $parameters);
246246
}
247+
248+
public function urlApiOAuth2TokenIntrospection(array $parameters = []): string
249+
{
250+
return $this->getModuleUrl(RoutesEnum::ApiOAuth2TokenIntrospection->value, $parameters);
251+
}
247252
}

0 commit comments

Comments
 (0)