|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Copyright 2014 SURFnet bv |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
9
|
|
|
* you may not use this file except in compliance with the License. |
|
10
|
|
|
* You may obtain a copy of the License at |
|
11
|
|
|
* |
|
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
13
|
|
|
* |
|
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17
|
|
|
* See the License for the specific language governing permissions and |
|
18
|
|
|
* limitations under the License. |
|
19
|
|
|
*/ |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\DependencyInjection; |
|
22
|
|
|
|
|
23
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
|
24
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
25
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
26
|
|
|
|
|
27
|
|
|
class Configuration implements ConfigurationInterface |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$treeBuilder = new TreeBuilder('surfnet_stepup_self_service_self_service'); |
|
32
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
|
33
|
|
|
|
|
34
|
|
|
$childNodes = $rootNode->children(); |
|
35
|
|
|
$this->appendEnabledSecondFactorTypesConfiguration($childNodes); |
|
36
|
|
|
$this->appendSecondFactorTestIdentityProvider($childNodes); |
|
37
|
|
|
$this->appendSessionConfiguration($childNodes); |
|
38
|
|
|
$this->appendActivationFlow($childNodes); |
|
39
|
|
|
|
|
40
|
|
|
return $treeBuilder; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private function appendSessionConfiguration(NodeBuilder $childNodes): void |
|
|
|
|
|
|
44
|
|
|
{ |
|
45
|
|
|
$childNodes |
|
46
|
|
|
->arrayNode('session_lifetimes') |
|
47
|
|
|
->isRequired() |
|
|
|
|
|
|
48
|
|
|
->children() |
|
|
|
|
|
|
49
|
|
|
->integerNode('max_absolute_lifetime') |
|
|
|
|
|
|
50
|
|
|
->isRequired() |
|
|
|
|
|
|
51
|
|
|
->defaultValue(3600) |
|
|
|
|
|
|
52
|
|
|
->info('The maximum lifetime of a session regardless of interaction by the user, in seconds.') |
|
|
|
|
|
|
53
|
|
|
->example('3600 -> 1 hour * 60 minutes * 60 seconds') |
|
|
|
|
|
|
54
|
|
|
->validate() |
|
|
|
|
|
|
55
|
|
|
->ifTrue( |
|
|
|
|
|
|
56
|
|
|
fn($lifetime): bool => !is_int($lifetime) |
|
57
|
|
|
) |
|
58
|
|
|
->thenInvalid('max_absolute_lifetime must be an integer') |
|
|
|
|
|
|
59
|
|
|
->end() |
|
|
|
|
|
|
60
|
|
|
->end() |
|
|
|
|
|
|
61
|
|
|
->integerNode('max_relative_lifetime') |
|
|
|
|
|
|
62
|
|
|
->isRequired() |
|
|
|
|
|
|
63
|
|
|
->defaultValue(600) |
|
|
|
|
|
|
64
|
|
|
->info( |
|
|
|
|
|
|
65
|
|
|
'The maximum relative lifetime of a session; the maximum allowed time between two ' |
|
66
|
|
|
. 'interactions by the user' |
|
67
|
|
|
) |
|
68
|
|
|
->example('600 -> 10 minutes * 60 seconds') |
|
|
|
|
|
|
69
|
|
|
->validate() |
|
|
|
|
|
|
70
|
|
|
->ifTrue( |
|
|
|
|
|
|
71
|
|
|
fn($lifetime): bool => !is_int($lifetime) |
|
72
|
|
|
) |
|
73
|
|
|
->thenInvalid('max_relative_lifetime must be an integer') |
|
|
|
|
|
|
74
|
|
|
->end() |
|
|
|
|
|
|
75
|
|
|
->end() |
|
|
|
|
|
|
76
|
|
|
->end() |
|
|
|
|
|
|
77
|
|
|
->end(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
private function appendSecondFactorTestIdentityProvider(NodeBuilder $childNodes): void |
|
|
|
|
|
|
81
|
|
|
{ |
|
82
|
|
|
$childNodes |
|
83
|
|
|
->arrayNode('second_factor_test_identity_provider') |
|
84
|
|
|
->isRequired() |
|
|
|
|
|
|
85
|
|
|
->children() |
|
|
|
|
|
|
86
|
|
|
->scalarNode('entity_id') |
|
|
|
|
|
|
87
|
|
|
->isRequired() |
|
|
|
|
|
|
88
|
|
|
->info('The EntityID of the remote identity provider') |
|
|
|
|
|
|
89
|
|
|
->end() |
|
|
|
|
|
|
90
|
|
|
->scalarNode('sso_url') |
|
|
|
|
|
|
91
|
|
|
->isRequired() |
|
|
|
|
|
|
92
|
|
|
->info('The name of the route to generate the SSO URL') |
|
|
|
|
|
|
93
|
|
|
->end() |
|
|
|
|
|
|
94
|
|
|
->scalarNode('certificate') |
|
|
|
|
|
|
95
|
|
|
->info('The contents of the certificate used to sign the AuthnResponse with') |
|
|
|
|
|
|
96
|
|
|
->end() |
|
|
|
|
|
|
97
|
|
|
->scalarNode('certificate_file') |
|
|
|
|
|
|
98
|
|
|
->info('A file containing the certificate used to sign the AuthnResponse with') |
|
|
|
|
|
|
99
|
|
|
->end() |
|
|
|
|
|
|
100
|
|
|
->end() |
|
|
|
|
|
|
101
|
|
|
->end(); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
private function appendEnabledSecondFactorTypesConfiguration(NodeBuilder $childNodes): void |
|
|
|
|
|
|
105
|
|
|
{ |
|
106
|
|
|
$childNodes |
|
107
|
|
|
->arrayNode('enabled_second_factors') |
|
108
|
|
|
->isRequired() |
|
|
|
|
|
|
109
|
|
|
->prototype('scalar') |
|
|
|
|
|
|
110
|
|
|
->end(); |
|
111
|
|
|
$childNodes |
|
112
|
|
|
->arrayNode('enabled_generic_second_factors') |
|
113
|
|
|
->isRequired() |
|
|
|
|
|
|
114
|
|
|
->prototype('array') |
|
|
|
|
|
|
115
|
|
|
->children() |
|
|
|
|
|
|
116
|
|
|
->scalarNode('loa') |
|
|
|
|
|
|
117
|
|
|
->isRequired() |
|
|
|
|
|
|
118
|
|
|
->info('The LOA level of the Gssp') |
|
|
|
|
|
|
119
|
|
|
->end() |
|
|
|
|
|
|
120
|
|
|
->end(); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
private function appendActivationFlow(NodeBuilder $childNodes): void |
|
|
|
|
|
|
124
|
|
|
{ |
|
125
|
|
|
$childNodes |
|
126
|
|
|
->arrayNode('preferred_activation_flow') |
|
127
|
|
|
->isRequired() |
|
128
|
|
|
->children() |
|
|
|
|
|
|
129
|
|
|
->scalarNode('query_string_field_name') |
|
|
|
|
|
|
130
|
|
|
->isRequired() |
|
|
|
|
|
|
131
|
|
|
->info('The name of the query string field that triggers the preferred activation flow') |
|
|
|
|
|
|
132
|
|
|
->end() |
|
|
|
|
|
|
133
|
|
|
->arrayNode('options') |
|
|
|
|
|
|
134
|
|
|
->prototype('scalar') |
|
|
|
|
|
|
135
|
|
|
->isRequired() |
|
|
|
|
|
|
136
|
|
|
->info('The options describing the preferred activation flow. Example: ra, self') |
|
|
|
|
|
|
137
|
|
|
->end() |
|
|
|
|
|
|
138
|
|
|
->end() |
|
|
|
|
|
|
139
|
|
|
->scalarNode('saml_attribute_field_name') |
|
|
|
|
|
|
140
|
|
|
->isRequired() |
|
|
|
|
|
|
141
|
|
|
->info('The name of the entitlement attribute (in SAML assertion) that is read to determine the preferred activation flow') |
|
|
|
|
|
|
142
|
|
|
->end() |
|
|
|
|
|
|
143
|
|
|
->arrayNode('saml_attributes') |
|
|
|
|
|
|
144
|
|
|
->isRequired() |
|
|
|
|
|
|
145
|
|
|
->children() |
|
|
|
|
|
|
146
|
|
|
->scalarNode('ra') |
|
|
|
|
|
|
147
|
|
|
->isRequired() |
|
|
|
|
|
|
148
|
|
|
->info('The entitlement attribute name for the ra vetting flow') |
|
|
|
|
|
|
149
|
|
|
->end() |
|
|
|
|
|
|
150
|
|
|
->scalarNode('self') |
|
|
|
|
|
|
151
|
|
|
->isRequired() |
|
|
|
|
|
|
152
|
|
|
->info('The entitlement attribute name for the self vetting flow') |
|
|
|
|
|
|
153
|
|
|
->end() |
|
|
|
|
|
|
154
|
|
|
->end() |
|
|
|
|
|
|
155
|
|
|
->end() |
|
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
->end() |
|
|
|
|
|
|
158
|
|
|
; |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|