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\StepupRa\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
|
|
|
/** |
26
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) |
27
|
|
|
*/ |
28
|
|
|
class Configuration implements ConfigurationInterface |
29
|
|
|
{ |
30
|
|
|
public function getConfigTreeBuilder() |
31
|
|
|
{ |
32
|
|
|
$treeBuilder = new TreeBuilder(); |
|
|
|
|
33
|
|
|
$rootNode = $treeBuilder->root('surfnet_stepup_ra_saml_stepup_provider'); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$this->addRoutesSection($rootNode); |
36
|
|
|
$this->addProvidersSection($rootNode); |
37
|
|
|
|
38
|
|
|
return $treeBuilder; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param ArrayNodeDefinition $rootNode |
43
|
|
|
*/ |
44
|
|
|
private function addRoutesSection(ArrayNodeDefinition $rootNode) |
45
|
|
|
{ |
46
|
|
|
$rootNode |
47
|
|
|
->children() |
48
|
|
|
->arrayNode('routes') |
49
|
|
|
->children() |
50
|
|
|
->scalarNode('consume_assertion') |
51
|
|
|
->isRequired() |
52
|
|
|
->validate() |
53
|
|
|
->ifTrue(function ($v) { |
54
|
|
|
return !is_string($v) || strlen($v) === 0; |
55
|
|
|
}) |
56
|
|
|
->thenInvalid('Consume assertion route must be a non-empty string') |
57
|
|
|
->end() |
58
|
|
|
->end() |
59
|
|
|
->scalarNode('metadata') |
60
|
|
|
->isRequired() |
61
|
|
|
->validate() |
62
|
|
|
->ifTrue(function ($v) { |
63
|
|
|
return !is_string($v) || strlen($v) === 0; |
64
|
|
|
}) |
65
|
|
|
->thenInvalid('Metadata route must be a non-empty string') |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->end() |
69
|
|
|
->end(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param ArrayNodeDefinition $rootNode |
74
|
|
|
*/ |
75
|
|
|
private function addProvidersSection(ArrayNodeDefinition $rootNode) |
76
|
|
|
{ |
77
|
|
|
/** @var ArrayNodeDefinition $protoType */ |
78
|
|
|
$protoType = $rootNode |
79
|
|
|
->children() |
80
|
|
|
->arrayNode('providers') |
81
|
|
|
->isRequired() |
82
|
|
|
->requiresAtLeastOneElement() |
83
|
|
|
->useAttributeAsKey('type') |
84
|
|
|
->prototype('array'); |
85
|
|
|
|
86
|
|
|
$protoType |
87
|
|
|
->children() |
88
|
|
|
->arrayNode('hosted') |
89
|
|
|
->children() |
90
|
|
|
->arrayNode('service_provider') |
91
|
|
|
->children() |
92
|
|
|
->scalarNode('public_key') |
93
|
|
|
->isRequired() |
94
|
|
|
->info('The absolute path to the public key used to sign AuthnRequests') |
95
|
|
|
->end() |
96
|
|
|
->scalarNode('private_key') |
97
|
|
|
->isRequired() |
98
|
|
|
->info('The absolute path to the private key used to sign AuthnRequests') |
99
|
|
|
->end() |
100
|
|
|
->end() |
101
|
|
|
->end() |
102
|
|
|
->arrayNode('metadata') |
103
|
|
|
->children() |
104
|
|
|
->scalarNode('public_key') |
105
|
|
|
->isRequired() |
106
|
|
|
->info('The absolute path to the public key used to sign the metadata') |
107
|
|
|
->end() |
108
|
|
|
->scalarNode('private_key') |
109
|
|
|
->isRequired() |
110
|
|
|
->info('The absolute path to the private key used to sign the metadata') |
111
|
|
|
->end() |
112
|
|
|
->end() |
113
|
|
|
->end() |
114
|
|
|
->end() |
115
|
|
|
->end() |
116
|
|
|
->arrayNode('remote') |
117
|
|
|
->children() |
118
|
|
|
->scalarNode('entity_id') |
119
|
|
|
->isRequired() |
120
|
|
|
->info('The EntityID of the remote identity provider') |
121
|
|
|
->end() |
122
|
|
|
->scalarNode('sso_url') |
123
|
|
|
->isRequired() |
124
|
|
|
->info('The name of the route to generate the SSO URL') |
125
|
|
|
->end() |
126
|
|
|
->scalarNode('certificate') |
127
|
|
|
->isRequired() |
128
|
|
|
->info( |
129
|
|
|
'The contents of the certificate used to sign the AuthnResponse with, if different from' |
130
|
|
|
. ' the public key configured below' |
131
|
|
|
) |
132
|
|
|
->end() |
133
|
|
|
->end() |
134
|
|
|
->end() |
135
|
|
|
->arrayNode('view_config') |
136
|
|
|
->children() |
137
|
|
|
->arrayNode('title') |
138
|
|
|
->children() |
139
|
|
|
->scalarNode('en_GB') |
140
|
|
|
->isRequired() |
141
|
|
|
->info('English gssp title translation') |
142
|
|
|
->end() |
143
|
|
|
->scalarNode('nl_NL') |
144
|
|
|
->isRequired() |
145
|
|
|
->info('Dutch gssp title translation') |
146
|
|
|
->end() |
147
|
|
|
->end() |
148
|
|
|
->end() |
149
|
|
|
->arrayNode('page_title') |
150
|
|
|
->children() |
151
|
|
|
->scalarNode('en_GB') |
152
|
|
|
->isRequired() |
153
|
|
|
->info('English page title translation') |
154
|
|
|
->end() |
155
|
|
|
->scalarNode('nl_NL') |
156
|
|
|
->isRequired() |
157
|
|
|
->info('Dutch alt page title translation') |
158
|
|
|
->end() |
159
|
|
|
->end() |
160
|
|
|
->end() |
161
|
|
|
->arrayNode('explanation') |
162
|
|
|
->children() |
163
|
|
|
->scalarNode('en_GB') |
164
|
|
|
->isRequired() |
165
|
|
|
->info('English explanation translation') |
166
|
|
|
->end() |
167
|
|
|
->scalarNode('nl_NL') |
168
|
|
|
->isRequired() |
169
|
|
|
->info('Dutch explanation translation') |
170
|
|
|
->end() |
171
|
|
|
->end() |
172
|
|
|
->end() |
173
|
|
|
->arrayNode('initiate') |
174
|
|
|
->children() |
175
|
|
|
->scalarNode('en_GB') |
176
|
|
|
->isRequired() |
177
|
|
|
->info('English initiate text translation') |
178
|
|
|
->end() |
179
|
|
|
->scalarNode('nl_NL') |
180
|
|
|
->isRequired() |
181
|
|
|
->info('Dutch initiate text translation') |
182
|
|
|
->end() |
183
|
|
|
->end() |
184
|
|
|
->end() |
185
|
|
|
->arrayNode('gssf_id_mismatch') |
186
|
|
|
->children() |
187
|
|
|
->scalarNode('en_GB') |
188
|
|
|
->isRequired() |
189
|
|
|
->info('English id mismatch text translation') |
190
|
|
|
->end() |
191
|
|
|
->scalarNode('nl_NL') |
192
|
|
|
->isRequired() |
193
|
|
|
->info('Dutch id mismatch text translation') |
194
|
|
|
->end() |
195
|
|
|
->end() |
196
|
|
|
->end() |
197
|
|
|
->end() |
198
|
|
|
->end() |
199
|
|
|
->end(); |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
|
This check looks for function calls that miss required arguments.