|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2015 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\SecondFactorOnlyBundle\DependencyInjection; |
|
20
|
|
|
|
|
21
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
|
22
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
23
|
|
|
use Symfony\Component\Config\FileLocator; |
|
24
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
25
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
26
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
27
|
|
|
|
|
28
|
|
|
class SurfnetStepupGatewaySecondFactorOnlyExtension extends Extension |
|
29
|
|
|
{ |
|
30
|
|
|
public function load(array $config, ContainerBuilder $container) |
|
31
|
|
|
{ |
|
32
|
|
|
$loader = new YamlFileLoader( |
|
33
|
|
|
$container, |
|
34
|
|
|
new FileLocator(__DIR__ . '/../Resources/config') |
|
35
|
|
|
); |
|
36
|
|
|
$loader->load('services.yml'); |
|
37
|
|
|
|
|
38
|
|
|
$this->replaceLoaAliasConfig($config, $container); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param array $config |
|
43
|
|
|
* @param ContainerBuilder $container |
|
44
|
|
|
*/ |
|
45
|
|
|
private function replaceLoaAliasConfig( |
|
46
|
|
|
array $config, |
|
47
|
|
|
ContainerBuilder $container |
|
48
|
|
|
) { |
|
49
|
|
|
$loaAliasMapping = []; |
|
50
|
|
|
foreach ($config[0]['loa_aliases'] as $mapping) { |
|
51
|
|
|
if (isset($loaAliasMapping[$mapping['loa']])) { |
|
52
|
|
|
throw new InvalidConfigurationException( |
|
53
|
|
|
'Duplicate loa identifiers in surfnet_stepup_gateway_gateway.loa_domains.gateway' |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$loaAliasMapping[$mapping['loa']] = $mapping['alias']; |
|
58
|
|
|
} |
|
59
|
|
|
$container |
|
60
|
|
|
->getDefinition('second_factor_only.loa_alias_lookup') |
|
61
|
|
|
->replaceArgument(0, $loaAliasMapping); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|