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 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
|
|
|
class OpenIdConnectSource implements Component |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Component[] |
26
|
|
|
*/ |
27
|
|
|
private $subComponents; |
28
|
|
|
|
29
|
|
|
public function __construct() |
30
|
|
|
{ |
31
|
|
|
$this->subComponents = [ |
32
|
|
|
new PairwiseSubjectSource(), |
33
|
|
|
new IdTokenSource(), |
34
|
|
|
new UserinfoEndpointSource(), |
35
|
|
|
new ResponseTypeSource(), |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function name(): string |
43
|
|
|
{ |
44
|
|
|
return 'openid_connect'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
|
|
public function load(array $configs, ContainerBuilder $container) |
51
|
|
|
{ |
52
|
|
|
if (!$configs['openid_connect']['enabled']) { |
53
|
|
|
return; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/openid_connect')); |
|
|
|
|
57
|
|
|
//$loader->load('openid_connect.php'); |
|
|
|
|
58
|
|
|
|
59
|
|
|
foreach ($this->subComponents as $subComponent) { |
60
|
|
|
$subComponent->load($configs, $container); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritdoc} |
66
|
|
|
*/ |
67
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
68
|
|
|
{ |
69
|
|
|
$childNode = $node->children() |
70
|
|
|
->arrayNode($this->name()) |
71
|
|
|
->canBeEnabled() |
72
|
|
|
->addDefaultsIfNotSet(); |
73
|
|
|
|
74
|
|
|
foreach ($this->subComponents as $subComponent) { |
75
|
|
|
$subComponent->getNodeDefinition($childNode); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
83
|
|
|
{ |
84
|
|
|
$updatedConfig = []; |
85
|
|
|
foreach ($this->subComponents as $subComponent) { |
86
|
|
|
$updatedConfig = array_merge( |
87
|
|
|
$updatedConfig, |
88
|
|
|
$subComponent->prepend($container, $config) |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return $updatedConfig; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
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.