|
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\StepupGateway\GatewayBundle\DependencyInjection; |
|
20
|
|
|
|
|
21
|
|
|
use Surfnet\StepupBundle\Exception\DomainException; |
|
22
|
|
|
use Surfnet\StepupBundle\Exception\InvalidArgumentException; |
|
23
|
|
|
use Surfnet\StepupBundle\Value\SecondFactorType; |
|
24
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
25
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
26
|
|
|
|
|
27
|
|
|
final class Configuration implements ConfigurationInterface |
|
28
|
|
|
{ |
|
29
|
|
|
public function getConfigTreeBuilder() |
|
30
|
|
|
{ |
|
31
|
|
|
$treeBuilder = new TreeBuilder(); |
|
32
|
|
|
|
|
33
|
|
|
$rootNode = $treeBuilder->root('surfnet_stepup_gateway_gateway'); |
|
34
|
|
|
|
|
35
|
|
|
$rootNode |
|
36
|
|
|
->children() |
|
37
|
|
|
->scalarNode('intrinsic_loa') |
|
38
|
|
|
->isRequired() |
|
39
|
|
|
->end() |
|
40
|
|
|
->arrayNode('enabled_second_factors') |
|
41
|
|
|
->isRequired() |
|
42
|
|
|
->prototype('scalar') |
|
43
|
|
|
->validate() |
|
44
|
|
|
->ifTrue(function ($type) { |
|
45
|
|
|
try { |
|
46
|
|
|
new SecondFactorType($type); |
|
47
|
|
|
} catch (InvalidArgumentException $e) { |
|
48
|
|
|
return true; |
|
49
|
|
|
} catch (DomainException $e) { |
|
50
|
|
|
return true; |
|
51
|
|
|
} |
|
52
|
|
|
}) |
|
53
|
|
|
->thenInvalid( |
|
54
|
|
|
'Enabled second factor type "%s" is not one of the valid types. See SecondFactorType' |
|
55
|
|
|
) |
|
56
|
|
|
->end() |
|
57
|
|
|
->end() |
|
58
|
|
|
->end() |
|
59
|
|
|
->arrayNode('loa_domains') |
|
60
|
|
|
->isRequired() |
|
61
|
|
|
->children() |
|
62
|
|
|
->arrayNode('gateway') |
|
63
|
|
|
->prototype('array') |
|
64
|
|
|
->children() |
|
65
|
|
|
->scalarNode('loa')->isRequired()->end() |
|
66
|
|
|
->scalarNode('ref')->isRequired()->end() |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->arrayNode('second_factor_only') |
|
71
|
|
|
->prototype('array') |
|
72
|
|
|
->children() |
|
73
|
|
|
->scalarNode('loa')->isRequired()->end() |
|
74
|
|
|
->scalarNode('ref')->isRequired()->end() |
|
75
|
|
|
->end() |
|
76
|
|
|
->end() |
|
77
|
|
|
->end() |
|
78
|
|
|
->end() |
|
79
|
|
|
->end() |
|
80
|
|
|
->end(); |
|
81
|
|
|
|
|
82
|
|
|
return $treeBuilder; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|