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\Endpoint\Authorization; |
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 ResponseModeSource implements Component |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Component[] |
26
|
|
|
*/ |
27
|
|
|
private $subComponents = []; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* AuthorizationEndpointResponseModeSource constructor. |
31
|
|
|
*/ |
32
|
|
|
public function __construct() |
33
|
|
|
{ |
34
|
|
|
$this->subComponents = [ |
35
|
|
|
new FormPostResponseModeSource() |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function load(array $configs, ContainerBuilder $container) |
43
|
|
|
{ |
44
|
|
|
$config = $configs['endpoint']['authorization']['response_mode']; |
45
|
|
|
$container->setParameter('oauth2_server.endpoint.authorization.response_mode.allow_response_mode_parameter', $config['allow_response_mode_parameter']); |
46
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint/authorization')); |
47
|
|
|
$loader->load('response_mode.php'); |
48
|
|
|
|
49
|
|
|
foreach ($this->subComponents as $subComponent) { |
50
|
|
|
$subComponent->load($configs, $container); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function name(): string |
58
|
|
|
{ |
59
|
|
|
return 'response_mode'; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode) |
66
|
|
|
{ |
67
|
|
|
$childNode = $node->children() |
68
|
|
|
->arrayNode($this->name()) |
69
|
|
|
->addDefaultsIfNotSet() |
70
|
|
|
->treatFalseLike([]) |
71
|
|
|
->treatNullLike([]); |
72
|
|
|
|
73
|
|
|
$childNode->children() |
74
|
|
|
->booleanNode('allow_response_mode_parameter') |
75
|
|
|
->defaultFalse() |
76
|
|
|
->end() |
77
|
|
|
->end(); |
78
|
|
|
|
79
|
|
|
foreach ($this->subComponents as $subComponent) { |
80
|
|
|
$subComponent->getNodeDefinition($childNode, $node); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
88
|
|
|
{ |
89
|
|
|
$updatedConfig = []; |
90
|
|
|
foreach ($this->subComponents as $subComponent) { |
91
|
|
|
$updatedConfig = array_merge( |
92
|
|
|
$updatedConfig, |
93
|
|
|
$subComponent->prepend($container, $config) |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $updatedConfig; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
|
|
public function build(ContainerBuilder $container) |
104
|
|
|
{ |
105
|
|
|
foreach ($this->subComponents as $component) { |
106
|
|
|
$component->build($container); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|