|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2014 SURFnet bv |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace Surfnet\StepupSelfService\SamlStepupProviderBundle\DependencyInjection; |
|
20
|
|
|
|
|
21
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
22
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
23
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
24
|
|
|
|
|
25
|
|
|
class Configuration implements ConfigurationInterface |
|
26
|
|
|
{ |
|
27
|
|
|
public function getConfigTreeBuilder() |
|
28
|
|
|
{ |
|
29
|
|
|
$treeBuilder = new TreeBuilder(); |
|
30
|
|
|
$rootNode = $treeBuilder->root('surfnet_stepup_self_service_saml_stepup_provider'); |
|
31
|
|
|
|
|
32
|
|
|
$this->addRoutesSection($rootNode); |
|
33
|
|
|
$this->addProvidersSection($rootNode); |
|
34
|
|
|
|
|
35
|
|
|
return $treeBuilder; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param ArrayNodeDefinition $rootNode |
|
40
|
|
|
*/ |
|
41
|
|
|
private function addRoutesSection(ArrayNodeDefinition $rootNode) |
|
42
|
|
|
{ |
|
43
|
|
|
$rootNode |
|
44
|
|
|
->children() |
|
45
|
|
|
->arrayNode('routes') |
|
46
|
|
|
->children() |
|
47
|
|
|
->scalarNode('consume_assertion') |
|
48
|
|
|
->isRequired() |
|
49
|
|
|
->validate() |
|
50
|
|
|
->ifTrue(function ($v) { |
|
51
|
|
|
return !is_string($v) || strlen($v) === 0; |
|
52
|
|
|
}) |
|
53
|
|
|
->thenInvalid('Consume assertion route must be a non-empty string') |
|
54
|
|
|
->end() |
|
55
|
|
|
->end() |
|
56
|
|
|
->scalarNode('metadata') |
|
57
|
|
|
->isRequired() |
|
58
|
|
|
->validate() |
|
59
|
|
|
->ifTrue(function ($v) { |
|
60
|
|
|
return !is_string($v) || strlen($v) === 0; |
|
61
|
|
|
}) |
|
62
|
|
|
->thenInvalid('Metadata route must be a non-empty string') |
|
63
|
|
|
->end() |
|
64
|
|
|
->end() |
|
65
|
|
|
->end() |
|
66
|
|
|
->end(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param ArrayNodeDefinition $rootNode |
|
71
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) |
|
72
|
|
|
*/ |
|
73
|
|
|
private function addProvidersSection(ArrayNodeDefinition $rootNode) |
|
74
|
|
|
{ |
|
75
|
|
|
/** @var ArrayNodeDefinition $protoType */ |
|
76
|
|
|
$protoType = $rootNode |
|
77
|
|
|
->children() |
|
78
|
|
|
->arrayNode('providers') |
|
79
|
|
|
->isRequired() |
|
80
|
|
|
->requiresAtLeastOneElement() |
|
81
|
|
|
->useAttributeAsKey('type') |
|
82
|
|
|
->prototype('array'); |
|
83
|
|
|
|
|
84
|
|
|
$protoType |
|
85
|
|
|
->children() |
|
86
|
|
|
->arrayNode('hosted') |
|
87
|
|
|
->children() |
|
88
|
|
|
->arrayNode('service_provider') |
|
89
|
|
|
->children() |
|
90
|
|
|
->scalarNode('public_key') |
|
91
|
|
|
->isRequired() |
|
92
|
|
|
->info('The absolute path to the public key used to sign AuthnRequests') |
|
93
|
|
|
->end() |
|
94
|
|
|
->scalarNode('private_key') |
|
95
|
|
|
->isRequired() |
|
96
|
|
|
->info('The absolute path to the private key used to sign AuthnRequests') |
|
97
|
|
|
->end() |
|
98
|
|
|
->end() |
|
99
|
|
|
->end() |
|
100
|
|
|
->arrayNode('metadata') |
|
101
|
|
|
->children() |
|
102
|
|
|
->scalarNode('public_key') |
|
103
|
|
|
->isRequired() |
|
104
|
|
|
->info('The absolute path to the public key used to sign the metadata') |
|
105
|
|
|
->end() |
|
106
|
|
|
->scalarNode('private_key') |
|
107
|
|
|
->isRequired() |
|
108
|
|
|
->info('The absolute path to the private key used to sign the metadata') |
|
109
|
|
|
->end() |
|
110
|
|
|
->end() |
|
111
|
|
|
->end() |
|
112
|
|
|
->end() |
|
113
|
|
|
->end() |
|
114
|
|
|
->arrayNode('remote') |
|
115
|
|
|
->children() |
|
116
|
|
|
->scalarNode('entity_id') |
|
117
|
|
|
->isRequired() |
|
118
|
|
|
->info('The EntityID of the remote identity provider') |
|
119
|
|
|
->end() |
|
120
|
|
|
->scalarNode('sso_url') |
|
121
|
|
|
->isRequired() |
|
122
|
|
|
->info('The name of the route to generate the SSO URL') |
|
123
|
|
|
->end() |
|
124
|
|
|
->scalarNode('certificate') |
|
125
|
|
|
->isRequired() |
|
126
|
|
|
->info( |
|
127
|
|
|
'The contents of the certificate used to sign the AuthnResponse with, if different from' |
|
128
|
|
|
. ' the public key configured below' |
|
129
|
|
|
) |
|
130
|
|
|
->end() |
|
131
|
|
|
->end() |
|
132
|
|
|
->end() |
|
133
|
|
|
->arrayNode('view_config') |
|
134
|
|
|
->children() |
|
135
|
|
|
->scalarNode('loa') |
|
136
|
|
|
->isRequired() |
|
137
|
|
|
->info('The loa level (for now 1-3 are supported)') |
|
138
|
|
|
->end() |
|
139
|
|
|
->scalarNode('logo') |
|
140
|
|
|
->isRequired() |
|
141
|
|
|
->info('The absolute path to the logo of the gssp') |
|
142
|
|
|
->end() |
|
143
|
|
|
->arrayNode('alt') |
|
144
|
|
|
->children() |
|
145
|
|
|
->scalarNode('en_GB') |
|
146
|
|
|
->isRequired() |
|
147
|
|
|
->info('English alt text translation') |
|
148
|
|
|
->end() |
|
149
|
|
|
->scalarNode('nl_NL') |
|
150
|
|
|
->isRequired() |
|
151
|
|
|
->info('Dutch alt text translation') |
|
152
|
|
|
->end() |
|
153
|
|
|
->end() |
|
154
|
|
|
->end() |
|
155
|
|
|
->arrayNode('title') |
|
156
|
|
|
->children() |
|
157
|
|
|
->scalarNode('en_GB') |
|
158
|
|
|
->isRequired() |
|
159
|
|
|
->info('English title of the gssp') |
|
160
|
|
|
->end() |
|
161
|
|
|
->scalarNode('nl_NL') |
|
162
|
|
|
->isRequired() |
|
163
|
|
|
->info('Dutch title of the gssp') |
|
164
|
|
|
->end() |
|
165
|
|
|
->end() |
|
166
|
|
|
->end() |
|
167
|
|
|
->arrayNode('description') |
|
168
|
|
|
->children() |
|
169
|
|
|
->scalarNode('en_GB') |
|
170
|
|
|
->isRequired() |
|
171
|
|
|
->info('English description of the gssp') |
|
172
|
|
|
->end() |
|
173
|
|
|
->scalarNode('nl_NL') |
|
174
|
|
|
->isRequired() |
|
175
|
|
|
->info('Dutch description of the gssp') |
|
176
|
|
|
->end() |
|
177
|
|
|
->end() |
|
178
|
|
|
->end() |
|
179
|
|
|
->arrayNode('button_use') |
|
180
|
|
|
->children() |
|
181
|
|
|
->scalarNode('en_GB') |
|
182
|
|
|
->isRequired() |
|
183
|
|
|
->info('English text shown on the use button') |
|
184
|
|
|
->end() |
|
185
|
|
|
->scalarNode('nl_NL') |
|
186
|
|
|
->isRequired() |
|
187
|
|
|
->info('Dutch text shown on the use button') |
|
188
|
|
|
->end() |
|
189
|
|
|
->end() |
|
190
|
|
|
->end() |
|
191
|
|
|
->arrayNode('initiate_title') |
|
192
|
|
|
->children() |
|
193
|
|
|
->scalarNode('en_GB') |
|
194
|
|
|
->isRequired() |
|
195
|
|
|
->info('English initiate title text') |
|
196
|
|
|
->end() |
|
197
|
|
|
->scalarNode('nl_NL') |
|
198
|
|
|
->isRequired() |
|
199
|
|
|
->info('Dutch initiate title text') |
|
200
|
|
|
->end() |
|
201
|
|
|
->end() |
|
202
|
|
|
->end() |
|
203
|
|
|
->arrayNode('initiate_button') |
|
204
|
|
|
->children() |
|
205
|
|
|
->scalarNode('en_GB') |
|
206
|
|
|
->isRequired() |
|
207
|
|
|
->info('English initiate button text') |
|
208
|
|
|
->end() |
|
209
|
|
|
->scalarNode('nl_NL') |
|
210
|
|
|
->isRequired() |
|
211
|
|
|
->info('Dutch initiate button text') |
|
212
|
|
|
->end() |
|
213
|
|
|
->end() |
|
214
|
|
|
->end() |
|
215
|
|
|
->arrayNode('explanation') |
|
216
|
|
|
->children() |
|
217
|
|
|
->scalarNode('en_GB') |
|
218
|
|
|
->isRequired() |
|
219
|
|
|
->info('English explanation for step 2') |
|
220
|
|
|
->end() |
|
221
|
|
|
->scalarNode('nl_NL') |
|
222
|
|
|
->isRequired() |
|
223
|
|
|
->info('Dutch explanation for step 2') |
|
224
|
|
|
->end() |
|
225
|
|
|
->end() |
|
226
|
|
|
->end() |
|
227
|
|
|
->arrayNode('authn_failed') |
|
228
|
|
|
->children() |
|
229
|
|
|
->scalarNode('en_GB') |
|
230
|
|
|
->isRequired() |
|
231
|
|
|
->info('English text shown when authn request failed') |
|
232
|
|
|
->end() |
|
233
|
|
|
->scalarNode('nl_NL') |
|
234
|
|
|
->isRequired() |
|
235
|
|
|
->info('Dutch text shown when authn request failed') |
|
236
|
|
|
->end() |
|
237
|
|
|
->end() |
|
238
|
|
|
->end() |
|
239
|
|
|
->arrayNode('pop_failed') |
|
240
|
|
|
->children() |
|
241
|
|
|
->scalarNode('en_GB') |
|
242
|
|
|
->isRequired() |
|
243
|
|
|
->info('English text shown on failed proof of posession') |
|
244
|
|
|
->end() |
|
245
|
|
|
->scalarNode('nl_NL') |
|
246
|
|
|
->isRequired() |
|
247
|
|
|
->info('Dutch text shown on failed proof of posession') |
|
248
|
|
|
->end() |
|
249
|
|
|
->end() |
|
250
|
|
|
->end() |
|
251
|
|
|
->end() |
|
252
|
|
|
->end() |
|
253
|
|
|
->end(); |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
|