|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\SecurityCenterModule\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
20
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
21
|
|
|
use Zikula\SecurityCenterModule\Listener\ClickjackProtectionListener; |
|
22
|
|
|
|
|
23
|
|
|
class ZikulaSecurityCenterExtension extends Extension implements PrependExtensionInterface |
|
24
|
|
|
{ |
|
25
|
|
|
public function prepend(ContainerBuilder $container) |
|
26
|
|
|
{ |
|
27
|
|
|
if (!isset($container->getExtensions()['framework'])) { |
|
28
|
|
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
$configs = $container->getExtensionConfig($this->getAlias()); |
|
31
|
|
|
$zikulaSCConfig = $this->processConfiguration(new Configuration(), $configs); |
|
32
|
|
|
$container->prependExtensionConfig('framework', ['session' => $zikulaSCConfig['session']]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
36
|
|
|
{ |
|
37
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); |
|
38
|
|
|
$loader->load('services.yaml'); |
|
39
|
|
|
|
|
40
|
|
|
$configuration = new Configuration(); |
|
41
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
42
|
|
|
|
|
43
|
|
|
$container->getDefinition(ClickjackProtectionListener::class) |
|
44
|
|
|
->setArgument('$xFrameOptions', $config['x_frame_options']); |
|
45
|
|
|
|
|
46
|
|
|
$container->setParameter('zikula.session.name', $config['session']['name']); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|