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; |
15
|
|
|
|
16
|
|
|
use Fluent\PhpConfigFileLoader; |
17
|
|
|
use OAuth2Framework\Bundle\Component\Component; |
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
19
|
|
|
use Symfony\Component\Config\FileLocator; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
|
22
|
|
|
class AuthorizationEndpointSource implements Component |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* AuthorizationEndpointSource constructor. |
26
|
|
|
*/ |
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
$this->addSubSource(new AuthorizationEndpointRequestObjectSource()); |
|
|
|
|
30
|
|
|
$this->addSubSource(new AuthorizationEndpointResponseModeSource()); |
|
|
|
|
31
|
|
|
$this->addSubSource(new AuthorizationEndpointPreConfiguredAuthorizationSource()); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
protected function continueLoading(string $path, ContainerBuilder $container, array $config) |
38
|
|
|
{ |
39
|
|
|
foreach ($config as $k => $v) { |
40
|
|
|
$container->setParameter($path.'.'.$k, $v); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$loader = new PhpConfigFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config/endpoint')); |
44
|
|
|
$loader->load('authorization.php'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
|
|
public function name(): string |
51
|
|
|
{ |
52
|
|
|
return 'authorization'; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
59
|
|
|
{ |
60
|
|
|
$node |
61
|
|
|
->children() |
62
|
|
|
->scalarNode('path') |
63
|
|
|
->info('The path to the authorization endpoint.') |
64
|
|
|
->defaultValue('/authorize') |
65
|
|
|
->end() |
66
|
|
|
->scalarNode('login_route_name') |
67
|
|
|
->info('The name of the login route. Will be converted into URL and used to redirect the user if not logged in. If you use "FOSUserBundle", the route name should be "fos_user_security_login".') |
68
|
|
|
->end() |
69
|
|
|
->arrayNode('login_route_parameters') |
70
|
|
|
->info('Parameters associated to the login route (if needed).') |
71
|
|
|
->useAttributeAsKey('name') |
72
|
|
|
->prototype('scalar')->end() |
73
|
|
|
->treatNullLike([]) |
74
|
|
|
->end() |
75
|
|
|
->scalarNode('template') |
76
|
|
|
->info('The consent page template.') |
77
|
|
|
->defaultValue('@OAuth2FrameworkBundle/authorization/authorization.html.twig') |
78
|
|
|
->end() |
79
|
|
|
->scalarNode('allow_token_type_parameter') |
80
|
|
|
->info('If true the "token_type" parameter is allowed, else it will be ignored.') |
81
|
|
|
->defaultFalse() |
82
|
|
|
->end() |
83
|
|
|
->scalarNode('enforce_state') |
84
|
|
|
->info('If true the "state" parameter is mandatory (highly recommended).') |
85
|
|
|
->defaultFalse() |
86
|
|
|
->end() |
87
|
|
|
->scalarNode('enforce_secured_redirect_uri') |
88
|
|
|
->info('If true only secured redirect URIs are allowed.') |
89
|
|
|
->defaultTrue() |
90
|
|
|
->end() |
91
|
|
|
->scalarNode('enforce_redirect_uri_storage') |
92
|
|
|
->info('If true redirect URIs must be registered by the client to be used.') |
93
|
|
|
->defaultTrue() |
94
|
|
|
->end() |
95
|
|
|
->end(); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|