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\OpenIdConnect; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Component; |
17
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\AuthorizationCode\AuthorizationCodeSource; |
18
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\ClientCredentials\ClientCredentialsSource; |
19
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\Implicit\ImplicitSource; |
20
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\JwtBearer\JwtBearerSource; |
21
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\None\NoneSource; |
22
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\RefreshToken\RefreshTokenSource; |
23
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\ResourceOwnerPasswordCredential\ResourceOwnerPasswordCredentialSource; |
24
|
|
|
use OAuth2Framework\Component\AuthorizationEndpoint\ResponseType; |
25
|
|
|
use OAuth2Framework\Component\TokenEndpoint\GrantType; |
26
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
27
|
|
|
use Symfony\Component\Config\FileLocator; |
28
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
29
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
30
|
|
|
|
31
|
|
|
class UserinfoEndpointSource implements Component |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var Component[] |
35
|
|
|
*/ |
36
|
|
|
private $subComponents; |
37
|
|
|
|
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
$this->subComponents = [ |
41
|
|
|
new UserinfoEndpointSignatureSource(), |
42
|
|
|
new UserinfoEndpointEncryptionSource(), |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function name(): string |
50
|
|
|
{ |
51
|
|
|
return 'userinfo_endpoint'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function load(array $configs, ContainerBuilder $container) |
58
|
|
|
{ |
59
|
|
|
if (!$configs['openid_connect']['userinfo_endpoint']['enabled']) { |
60
|
|
|
return; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/openid_connect')); |
|
|
|
|
64
|
|
|
//$loader->load('userinfo_endpoint.php'); |
|
|
|
|
65
|
|
|
|
66
|
|
|
foreach ($this->subComponents as $subComponent) { |
67
|
|
|
$subComponent->load($configs, $container); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
75
|
|
|
{ |
76
|
|
|
$childNode = $node->children() |
77
|
|
|
->arrayNode($this->name()) |
78
|
|
|
->canBeEnabled() |
79
|
|
|
->addDefaultsIfNotSet(); |
80
|
|
|
|
81
|
|
|
$childNode->children() |
82
|
|
|
->scalarNode('path') |
83
|
|
|
->defaultValue('/userinfo') |
84
|
|
|
->end() |
85
|
|
|
->end(); |
86
|
|
|
|
87
|
|
|
foreach ($this->subComponents as $subComponent) { |
88
|
|
|
$subComponent->getNodeDefinition($childNode); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
96
|
|
|
{ |
97
|
|
|
$updatedConfig = []; |
98
|
|
|
foreach ($this->subComponents as $subComponent) { |
99
|
|
|
$updatedConfig = array_merge( |
100
|
|
|
$updatedConfig, |
101
|
|
|
$subComponent->prepend($container, $config) |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $updatedConfig; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.