|
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\Component\OpenIdConnect; |
|
15
|
|
|
|
|
16
|
|
|
use OAuth2Framework\Bundle\Component\Component; |
|
17
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
18
|
|
|
use Symfony\Component\Config\FileLocator; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
|
21
|
|
|
|
|
22
|
|
|
class UserinfoEndpointSignatureSource implements Component |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function name(): string |
|
28
|
|
|
{ |
|
29
|
|
|
return 'signature'; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* {@inheritdoc} |
|
34
|
|
|
*/ |
|
35
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
36
|
|
|
{ |
|
37
|
|
|
if (!$configs['openid_connect']['userinfo_endpoint']['signature']['enabled']) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config/openid_connect')); |
|
|
|
|
|
|
42
|
|
|
//$loader->load('userinfo_endpoint.php'); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode) |
|
49
|
|
|
{ |
|
50
|
|
|
$node->children() |
|
51
|
|
|
->arrayNode($this->name()) |
|
52
|
|
|
->canBeEnabled() |
|
53
|
|
|
->validate() |
|
54
|
|
|
->ifTrue(function ($config) { |
|
55
|
|
|
return true === $config['enabled'] && empty($config['signature_algorithms']); |
|
56
|
|
|
}) |
|
57
|
|
|
->thenInvalid('You must set at least one signature algorithm.') |
|
58
|
|
|
->end() |
|
59
|
|
|
->children() |
|
60
|
|
|
->arrayNode('signature_algorithms') |
|
61
|
|
|
->info('Signature algorithm used to sign the user information.') |
|
62
|
|
|
->useAttributeAsKey('name') |
|
63
|
|
|
->scalarPrototype()->end() |
|
64
|
|
|
->treatNullLike([]) |
|
65
|
|
|
->treatFalseLike([]) |
|
66
|
|
|
->end() |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* {@inheritdoc} |
|
74
|
|
|
*/ |
|
75
|
|
|
public function build(ContainerBuilder $container) |
|
76
|
|
|
{ |
|
77
|
|
|
//Nothing to do |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* {@inheritdoc} |
|
82
|
|
|
*/ |
|
83
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
|
84
|
|
|
{ |
|
85
|
|
|
/*Assertion::keyExists($bundleConfig['key_set'], 'signature', 'The signature key set must be enabled.'); |
|
|
|
|
|
|
86
|
|
|
$currentPath = $path.'['.$this->name().']'; |
|
87
|
|
|
$accessor = PropertyAccess::createPropertyAccessor(); |
|
88
|
|
|
$sourceConfig = $accessor->getValue($bundleConfig, $currentPath); |
|
89
|
|
|
|
|
90
|
|
|
ConfigurationHelper::addJWSBuilder($container, 'oauth2_server.userinfo', $sourceConfig['signature_algorithms'], false);*/ |
|
91
|
|
|
return []; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.