1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2017 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\Bundle\Server\ClientManagerPlugin\DependencyInjection\Compiler; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
19
|
|
|
|
20
|
|
|
class ClientManagementCompilerPass implements CompilerPassInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function process(ContainerBuilder $container) |
26
|
|
|
{ |
27
|
|
|
if (!$container->hasDefinition('oauth2_server.client_registration_endpoint') || !$container->hasDefinition('oauth2_server.client_configuration_endpoint')) { |
28
|
|
|
return; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$client_registration_endpoint = $container->getDefinition('oauth2_server.client_registration_endpoint'); |
32
|
|
|
$client_configuration_endpoint = $container->getDefinition('oauth2_server.client_configuration_endpoint'); |
33
|
|
|
|
34
|
|
|
if (true === $container->getParameter('oauth2_server.initial_access_token.enabled')) { |
35
|
|
|
$client_registration_endpoint->addMethodCall('enableInitialAccessTokenSupport', [ |
36
|
|
|
new Reference($container->getAlias('oauth2_server.initial_access_token.manager')), |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
$is_initial_access_token_required = $container->getParameter('oauth2_server.initial_access_token.required'); |
40
|
|
|
$method = sprintf('%sallowRegistrationWithoutInitialAccessToken', $is_initial_access_token_required ? 'dis' : ''); |
41
|
|
|
$client_registration_endpoint->addMethodCall($method, []); |
42
|
|
|
} |
43
|
|
|
if (true === $container->getParameter('oauth2_server.software_statement.enabled')) { |
44
|
|
|
$client_registration_endpoint->addMethodCall('enableSoftwareStatementSupport', [ |
45
|
|
|
new Reference('jose.jwt_loader.oauth2_server_software_statement'), |
46
|
|
|
new Reference($container->getAlias('oauth2_server.software_statement.key_set')), |
47
|
|
|
]); |
48
|
|
|
$client_configuration_endpoint->addMethodCall('enableSoftwareStatementSupport', [ |
49
|
|
|
new Reference('jose.jwt_loader.oauth2_server_software_statement'), |
50
|
|
|
new Reference($container->getAlias('oauth2_server.software_statement.key_set')), |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
$is_software_statement_required = $container->getParameter('oauth2_server.software_statement.required'); |
54
|
|
|
$method = sprintf('%sallowRegistrationWithoutSoftwareStatement', $is_software_statement_required ? 'dis' : ''); |
55
|
|
|
$client_registration_endpoint->addMethodCall($method, []); |
56
|
|
|
$client_configuration_endpoint->addMethodCall($method, []); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|