Skip to content

Commit da38910

Browse files
committed
Start with Credential Issuer and OAuth2 configuration discovery
1 parent 8ae7d1e commit da38910

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

routing/routes/routes.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
use SimpleSAML\Module\oidc\Controllers\Federation\EntityStatementController;
1818
use SimpleSAML\Module\oidc\Controllers\Federation\SubordinateListingsController;
1919
use SimpleSAML\Module\oidc\Controllers\JwksController;
20+
use SimpleSAML\Module\oidc\Controllers\OAuth2\OAuth2ServerConfigurationController;
2021
use SimpleSAML\Module\oidc\Controllers\UserInfoController;
22+
use SimpleSAML\Module\oidc\Controllers\VerifiableCredentials\CredentialIssuerConfigurationController;
2123
use SimpleSAML\OpenID\Codebooks\HttpMethodsEnum;
2224
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2325

@@ -86,6 +88,13 @@
8688
$routes->add(RoutesEnum::Jwks->name, RoutesEnum::Jwks->value)
8789
->controller([JwksController::class, 'jwks']);
8890

91+
/*****************************************************************************************************************
92+
* OAuth 2.0 Authorization Server
93+
****************************************************************************************************************/
94+
95+
$routes->add(RoutesEnum::OAuth2Configuration->name, RoutesEnum::OAuth2Configuration->value)
96+
->controller(OAuth2ServerConfigurationController::class);
97+
8998
/*****************************************************************************************************************
9099
* OpenID Federation
91100
****************************************************************************************************************/
@@ -101,4 +110,12 @@
101110
$routes->add(RoutesEnum::FederationList->name, RoutesEnum::FederationList->value)
102111
->controller([SubordinateListingsController::class, 'list'])
103112
->methods([HttpMethodsEnum::GET->value]);
113+
114+
/*****************************************************************************************************************
115+
* OpenID Verifiable Credential Issuance
116+
****************************************************************************************************************/
117+
118+
$routes->add(RoutesEnum::CredentialIssuerConfiguration->name, RoutesEnum::CredentialIssuerConfiguration->value)
119+
->controller([CredentialIssuerConfigurationController::class, 'configuration'])
120+
->methods([HttpMethodsEnum::GET->value]);
104121
};

src/Codebooks/RoutesEnum.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,24 @@ enum RoutesEnum: string
4040
case Jwks = 'jwks';
4141
case EndSession = 'end-session';
4242

43+
/*****************************************************************************************************************
44+
* OAuth 2.0 Authorization Server
45+
****************************************************************************************************************/
46+
47+
// OAuth 2.0 Authorization Server Metadata https://www.rfc-editor.org/rfc/rfc8414.html
48+
case OAuth2Configuration = '/.well-known/oauth-authorization-server';
49+
4350
/*****************************************************************************************************************
4451
* OpenID Federation
4552
****************************************************************************************************************/
4653

4754
case FederationConfiguration = '.well-known/openid-federation';
4855
case FederationFetch = 'federation/fetch';
4956
case FederationList = 'federation/list';
57+
58+
/*****************************************************************************************************************
59+
* OpenID Verifiable Credential Issuance
60+
****************************************************************************************************************/
61+
62+
case CredentialIssuerConfiguration = '.well-known/openid-credential-issuer';
5063
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Module\oidc\Controllers\OAuth2;
6+
7+
use SimpleSAML\Module\oidc\Services\OpMetadataService;
8+
use SimpleSAML\Module\oidc\Utils\Routes;
9+
use Symfony\Component\HttpFoundation\JsonResponse;
10+
11+
class OAuth2ServerConfigurationController
12+
{
13+
public function __construct(
14+
protected readonly OpMetadataService $opMetadataService,
15+
protected readonly Routes $routes,
16+
) {
17+
}
18+
19+
public function __invoke(): JsonResponse
20+
{
21+
// We'll reuse OIDC configuration.
22+
return $this->routes->newJsonResponse(
23+
$this->opMetadataService->getMetadata(),
24+
);
25+
26+
// TODO mivanci Add ability for claim 'signed_metadata' when moving to simplesamlphp/openid, as per
27+
// https://www.rfc-editor.org/rfc/rfc8414.html#section-2.1
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Module\oidc\Controllers\VerifiableCredentials;
6+
7+
use SimpleSAML\Module\oidc\ModuleConfig;
8+
use SimpleSAML\Module\oidc\Utils\Routes;
9+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
10+
use Symfony\Component\HttpFoundation\Response;
11+
12+
class CredentialIssuerConfigurationController
13+
{
14+
public function __construct(
15+
protected readonly ModuleConfig $moduleConfig,
16+
protected readonly Routes $routes,
17+
) {
18+
}
19+
20+
public function configuration(): Response
21+
{
22+
$configuration = [
23+
ClaimsEnum::CredentialIssuer->value => $this->moduleConfig->getIssuer(),
24+
];
25+
26+
return $this->routes->newJsonResponse($configuration);
27+
}
28+
}

0 commit comments

Comments
 (0)