1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rezzza\SecurityBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
9
|
|
|
use Symfony\Component\Config\Definition\Processor; |
10
|
|
|
use Rezzza\SecurityBundle\Security\Firewall\Context; |
11
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* RezzzaSecurityExtension |
15
|
|
|
* |
16
|
|
|
* @uses Extension |
17
|
|
|
* @author Stephane PY <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class RezzzaSecurityExtension extends Extension |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
|
|
public function load(array $configs, ContainerBuilder $container) |
25
|
|
|
{ |
26
|
|
|
$processor = new Processor(); |
27
|
|
|
$configuration = new Configuration(); |
28
|
|
|
|
29
|
|
|
$config = $processor->processConfiguration($configuration, $configs); |
30
|
|
|
|
31
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/services')); |
32
|
|
|
|
33
|
|
|
$loader->load('security.xml'); |
34
|
|
|
|
35
|
|
|
$container->setParameter('rezzza.security.request_obfuscator.enabled', $config['request_obfuscator']['enabled']); |
36
|
|
|
|
37
|
|
|
if ($container->getParameter('rezzza.security.request_obfuscator.enabled')) { |
38
|
|
|
$loader->load('request_obfuscator.xml'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$firewalls = $config['firewalls']; |
42
|
|
|
|
43
|
|
|
foreach ($firewalls as $name => $data) { |
44
|
|
|
$serviceName = sprintf('rezzza.security.signature_config.%s', $name); |
45
|
|
|
|
46
|
|
|
$definition = new Definition('Rezzza\SecurityBundle\Security\Firewall\SignatureConfig'); |
47
|
|
|
$definition->addArgument($data['replay_protection']); |
48
|
|
|
$definition->addArgument($data['algorithm']); |
49
|
|
|
$definition->addArgument($data['secret']); |
50
|
|
|
|
51
|
|
|
$container->setDefinition($serviceName, $definition); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|