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\Endpoint; |
15
|
|
|
|
16
|
|
|
use Fluent\PhpConfigFileLoader; |
17
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Component; |
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
19
|
|
|
use Symfony\Component\Config\FileLocator; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
|
22
|
|
|
final class ClientConfigurationSource implements Component |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
protected function continueLoading(string $path, ContainerBuilder $container, array $config) |
28
|
|
|
{ |
29
|
|
|
foreach ($config as $k => $v) { |
30
|
|
|
$container->setParameter($path.'.'.$k, $v); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$loader = new PhpConfigFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint')); |
34
|
|
|
$loader->load('client_configuration.php'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function name(): string |
41
|
|
|
{ |
42
|
|
|
return 'client_configuration'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
49
|
|
|
{ |
50
|
|
|
|
51
|
|
|
$node |
|
|
|
|
52
|
|
|
->validate() |
53
|
|
|
->ifTrue(function ($config) { |
54
|
|
|
return true === $config['enabled'] && empty($config['realm']); |
55
|
|
|
}) |
56
|
|
|
->thenInvalid('The option "realm" must be set.') |
57
|
|
|
->end() |
58
|
|
|
->children() |
59
|
|
|
->scalarNode('realm')->end() |
60
|
|
|
->booleanNode('authorization_header')->defaultTrue()->end() |
61
|
|
|
->booleanNode('query_string')->defaultFalse()->end() |
62
|
|
|
->booleanNode('request_body')->defaultFalse()->end() |
63
|
|
|
->scalarNode('path')->defaultValue('/client/configure/{client_id}')->end() |
64
|
|
|
->end(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|