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\Bundle\DependencyInjection\Component\TokenEndpointAuthMethod; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Component; |
17
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
18
|
|
|
use Symfony\Component\Config\FileLocator; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
20
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
21
|
|
|
|
22
|
|
|
final class TokenEndpointAuthMethodSource implements Component |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @return string |
26
|
|
|
*/ |
27
|
|
|
public function name(): string |
28
|
|
|
{ |
29
|
|
|
return 'token_endpoint_auth_method'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public function load(array $configs, ContainerBuilder $container) |
36
|
|
|
{ |
37
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/token_endpoint_auth_method')); |
38
|
|
|
$loader->load('token_endpoint_auth_method.php'); |
39
|
|
|
|
40
|
|
|
if ($configs['token_endpoint_auth_method']['none']['enabled']) { |
41
|
|
|
$loader->load('none.php'); |
42
|
|
|
} |
43
|
|
|
if ($configs['token_endpoint_auth_method']['client_secret_basic']['enabled']) { |
44
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_secret_basic.realm', $configs['token_endpoint_auth_method']['client_secret_basic']['realm']); |
45
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_secret_basic.secret_lifetime', $configs['token_endpoint_auth_method']['client_secret_basic']['secret_lifetime']); |
46
|
|
|
$loader->load('client_secret_basic.php'); |
47
|
|
|
} |
48
|
|
|
if ($configs['token_endpoint_auth_method']['client_secret_post']['enabled']) { |
49
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_secret_post.secret_lifetime', $configs['token_endpoint_auth_method']['client_secret_post']['secret_lifetime']); |
50
|
|
|
$loader->load('client_secret_post.php'); |
51
|
|
|
} |
52
|
|
|
if ($configs['token_endpoint_auth_method']['client_assertion_jwt']['enabled']) { |
53
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_assertion_jwt.secret_lifetime', $configs['token_endpoint_auth_method']['client_assertion_jwt']['secret_lifetime']); |
54
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_assertion_jwt.signature_algorithms', $configs['token_endpoint_auth_method']['client_assertion_jwt']['signature_algorithms']); |
55
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_assertion_jwt.claim_checkers', $configs['token_endpoint_auth_method']['client_assertion_jwt']['claim_checkers']); |
56
|
|
|
$container->setParameter('oauth2_server.token_endpoint_auth_method.client_assertion_jwt.header_checkers', $configs['token_endpoint_auth_method']['client_assertion_jwt']['header_checkers']); |
57
|
|
|
$loader->load('client_assertion_jwt.php'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
65
|
|
|
{ |
66
|
|
|
$node->children() |
67
|
|
|
->arrayNode($this->name()) |
68
|
|
|
->addDefaultsIfNotSet() |
69
|
|
|
->children() |
70
|
|
|
->arrayNode('none') |
71
|
|
|
->info('The "none" authentication method is designed for public clients') |
72
|
|
|
->canBeEnabled() |
73
|
|
|
->end() |
74
|
|
|
->arrayNode('client_secret_basic') |
75
|
|
|
->canBeEnabled() |
76
|
|
|
->children() |
77
|
|
|
->scalarNode('realm') |
78
|
|
|
->isRequired() |
79
|
|
|
->info('The realm displayed in the authentication header') |
80
|
|
|
->end() |
81
|
|
|
->integerNode('secret_lifetime') |
82
|
|
|
->defaultValue(60 * 60 * 24 * 14) |
83
|
|
|
->min(0) |
84
|
|
|
->info('Secret lifetime (in seconds; 0 = unlimited)') |
85
|
|
|
->end() |
86
|
|
|
->end() |
87
|
|
|
->end() |
88
|
|
|
->arrayNode('client_secret_post') |
89
|
|
|
->canBeEnabled() |
90
|
|
|
->children() |
91
|
|
|
->integerNode('secret_lifetime') |
92
|
|
|
->defaultValue(60 * 60 * 24 * 14) |
93
|
|
|
->min(0) |
94
|
|
|
->info('Secret lifetime (in seconds; 0 = unlimited)') |
95
|
|
|
->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
->arrayNode('client_assertion_jwt') |
99
|
|
|
->canBeEnabled() |
100
|
|
|
->info('This method comprises the "client_secret_jwt" and the "private_key_jwt" authentication methods') |
101
|
|
|
->children() |
102
|
|
|
->integerNode('secret_lifetime') |
103
|
|
|
->info('Secret lifetime (in seconds; 0 = unlimited) applicable to the "client_secret_jwt" authentication method') |
104
|
|
|
->defaultValue(60 * 60 * 24 * 14) |
105
|
|
|
->min(0) |
106
|
|
|
->end() |
107
|
|
|
->arrayNode('signature_algorithms') |
108
|
|
|
->info('Supported signature algorithms.') |
109
|
|
|
->useAttributeAsKey('name') |
110
|
|
|
->prototype('scalar')->end() |
111
|
|
|
->treatNullLike([]) |
112
|
|
|
->end() |
113
|
|
|
->arrayNode('claim_checkers') |
114
|
|
|
->info('Claim checkers for incoming assertions.') |
115
|
|
|
->useAttributeAsKey('name') |
116
|
|
|
->prototype('scalar')->end() |
117
|
|
|
->treatNullLike([]) |
118
|
|
|
->end() |
119
|
|
|
->arrayNode('header_checkers') |
120
|
|
|
->info('Header checkers for incoming assertions.') |
121
|
|
|
->useAttributeAsKey('name') |
122
|
|
|
->prototype('scalar')->end() |
123
|
|
|
->treatNullLike([]) |
124
|
|
|
->end() |
125
|
|
|
->end() |
126
|
|
|
->end() |
127
|
|
|
->end() |
128
|
|
|
->end() |
129
|
|
|
->end(); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* {@inheritdoc} |
134
|
|
|
*/ |
135
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
136
|
|
|
{ |
137
|
|
|
//Nothing to do |
138
|
|
|
return []; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|