|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* The MIT License (MIT) |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
|
9
|
|
|
* |
|
10
|
|
|
* This software may be modified and distributed under the terms |
|
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace OAuth2Framework\ServerBundle\Component\OpenIdConnect\Compiler; |
|
15
|
|
|
|
|
16
|
|
|
use OAuth2Framework\ServerBundle\Service\MetadataBuilder; |
|
17
|
|
|
use OAuth2Framework\Component\OpenIdConnect\UserInfo\UserInfo; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
21
|
|
|
|
|
22
|
|
|
class IdTokenMetadataCompilerPass implements CompilerPassInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function process(ContainerBuilder $container) |
|
28
|
|
|
{ |
|
29
|
|
|
if (!$container->hasDefinition(MetadataBuilder::class) || !$container->hasDefinition(UserInfo::class)) { |
|
30
|
|
|
return; |
|
31
|
|
|
} |
|
32
|
|
|
$metadata = $container->getDefinition(MetadataBuilder::class); |
|
33
|
|
|
|
|
34
|
|
|
$metadata->addMethodCall('setUserinfo', [new Reference(UserInfo::class)]); |
|
35
|
|
|
$metadata->addMethodCall('addKeyValuePair', ['claim_types_supported', ['normal', 'aggregated', 'distributed']]); |
|
36
|
|
|
$metadata->addMethodCall('addKeyValuePair', ['claims_parameter_supported', true]); |
|
37
|
|
|
$metadata->addMethodCall('addKeyValuePair', ['id_token_signing_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.signature_algorithms')]); |
|
38
|
|
|
if (true === $container->getParameter('oauth2_server.openid_connect.id_token.encryption.enabled')) { |
|
39
|
|
|
$metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.key_encryption_algorithms')]); |
|
40
|
|
|
$metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_enc_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.content_encryption_algorithms')]); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|