Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

SecurityPass.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler;
8
9 use eZ\Publish\Core\MVC\Symfony\Security\Authentication\AnonymousAuthenticationProvider;
10 use eZ\Publish\Core\MVC\Symfony\Security\Authentication\DefaultAuthenticationSuccessHandler;
11 use eZ\Publish\Core\MVC\Symfony\Security\Authentication\RememberMeRepositoryAuthenticationProvider;
12 use eZ\Publish\Core\MVC\Symfony\Security\Authentication\RepositoryAuthenticationProvider;
13 use eZ\Publish\Core\MVC\Symfony\Security\HttpUtils;
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Reference;
17
22 class SecurityPass implements CompilerPassInterface
23 {
24 public const CONSTANT_AUTH_TIME_SETTING = 'ibexa.security.authentication.constant_auth_time';
25
26 public const CONSTANT_AUTH_TIME_DEFAULT = 1.0;
27
28 public function process(ContainerBuilder $container)
29 {
30 if (!($container->hasDefinition('security.authentication.provider.dao') &&
31 $container->hasDefinition('security.authentication.provider.rememberme') &&
32 $container->hasDefinition('security.authentication.provider.anonymous'))) {
33 return;
34 }
35
36 $configResolverRef = new Reference('ezpublish.config.resolver');
37 $repositoryReference = new Reference('ezpublish.api.repository');
38 $loggerReference = new Reference('logger');
39
40 // Override and inject the Repository in the authentication provider.
41 // We need it for checking user credentials
42 $daoAuthenticationProviderDef = $container->findDefinition('security.authentication.provider.dao');
43 $daoAuthenticationProviderDef->setClass(RepositoryAuthenticationProvider::class);
44 $daoAuthenticationProviderDef->addMethodCall(
45 'setRepository',
46 [$repositoryReference]
47 );
48 $daoAuthenticationProviderDef->addMethodCall(
49 'setConstantAuthTime',
50 [
51 $container->hasParameter(self::CONSTANT_AUTH_TIME_SETTING) ?
52 (float)$container->getParameter(self::CONSTANT_AUTH_TIME_SETTING) :
53 self::CONSTANT_AUTH_TIME_DEFAULT,
54 ]
55 );
56 $daoAuthenticationProviderDef->addMethodCall(
57 'setLogger',
58 [$loggerReference]
59 );
60
61 $rememberMeAuthenticationProviderDef = $container->findDefinition('security.authentication.provider.rememberme');
62 $rememberMeAuthenticationProviderDef->setClass(RememberMeRepositoryAuthenticationProvider::class);
63 $rememberMeAuthenticationProviderDef->addMethodCall(
64 'setRepository',
65 [$repositoryReference]
66 );
67
68 $anonymousAuthenticationProviderDef = $container->findDefinition('security.authentication.provider.anonymous');
69 $anonymousAuthenticationProviderDef->setClass(AnonymousAuthenticationProvider::class);
70 $anonymousAuthenticationProviderDef->addMethodCall(
71 'setRepository',
72 [$repositoryReference]
73 );
74
75 $anonymousAuthenticationProviderDef->addMethodCall(
76 'setConfigResolver',
77 [$configResolverRef]
78 );
79
80 if (!$container->hasDefinition('security.http_utils')) {
81 return;
82 }
83
84 $httpUtilsDef = $container->findDefinition('security.http_utils');
85 $httpUtilsDef->setClass(HttpUtils::class);
86 $httpUtilsDef->addMethodCall(
87 'setSiteAccess',
88 [new Reference('ezpublish.siteaccess')]
89 );
90
91 if (!$container->hasDefinition('security.authentication.success_handler')) {
92 return;
93 }
94
95 $successHandlerDef = $container->getDefinition('security.authentication.success_handler');
96 $successHandlerDef->setClass(DefaultAuthenticationSuccessHandler::class);
97 $successHandlerDef->addMethodCall(
98 'setConfigResolver',
99 [$configResolverRef]
100 );
101 }
102 }
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\SecurityPass
Security related compiler pass.
Definition: SecurityPass.php:23
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\SecurityPass\CONSTANT_AUTH_TIME_SETTING
const CONSTANT_AUTH_TIME_SETTING
Definition: SecurityPass.php:24
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\SecurityPass\CONSTANT_AUTH_TIME_DEFAULT
const CONSTANT_AUTH_TIME_DEFAULT
Definition: SecurityPass.php:26
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\SecurityPass\process
process(ContainerBuilder $container)
Definition: SecurityPass.php:28
eZ\Publish\Core\MVC\Symfony\Security\Authentication\AnonymousAuthenticationProvider
Definition: AnonymousAuthenticationProvider.php:16
eZ\Publish\Core\MVC\Symfony\Security\Authentication\DefaultAuthenticationSuccessHandler
Definition: DefaultAuthenticationSuccessHandler.php:13
eZ\Publish\Core\MVC\Symfony\Security\Authentication\RememberMeRepositoryAuthenticationProvider
Definition: RememberMeRepositoryAuthenticationProvider.php:15
eZ\Publish\Core\MVC\Symfony\Security\Authentication\RepositoryAuthenticationProvider
Definition: RepositoryAuthenticationProvider.php:21
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils
Definition: HttpUtils.php:15
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler
Definition: AsseticPass.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.