diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 35cc7b1b4d91..b1957efe3d20 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -478,6 +478,12 @@ private function createFirewall(ContainerBuilder $container, string $id, array $ ->replaceArgument(0, new Reference($managerId)) ; + // user checker listener + $container + ->setDefinition('security.listener.user_checker.'.$id, new ChildDefinition('security.listener.user_checker')) + ->replaceArgument(0, new Reference('security.user_checker.'.$id)) + ->addTag('kernel.event_subscriber', ['dispatcher' => $firewallEventDispatcherId]); + $listeners[] = new Reference('security.firewall.authenticator.'.$id); } diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml index 65bc75594169..98936b87ff43 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml @@ -54,9 +54,8 @@ - - - + + user checker expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('The security option "always_authenticate_before_granting" cannot be used when "enable_authenticator_manager" is set to true. If you rely on this behavior, set it to false.'); @@ -559,7 +561,7 @@ public function provideConfigureCustomAuthenticatorData() ]; } - public function testCompilesWithoutSessionListenerWithStatelessFirewallWithAuthenticationManager() + public function testCompilesWithoutSessionListenerWithStatelessFirewallWithAuthenticatorManager() { $container = $this->getRawContainer(); @@ -580,7 +582,7 @@ public function testCompilesWithoutSessionListenerWithStatelessFirewallWithAuthe $this->assertFalse($container->has('security.listener.session.'.$firewallId)); } - public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthenticationManager() + public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthenticatorManager() { $container = $this->getRawContainer(); @@ -601,6 +603,37 @@ public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthent $this->assertTrue($container->has('security.listener.session.'.$firewallId)); } + /** + * @dataProvider provideUserCheckerConfig + */ + public function testUserCheckerWithAuthenticatorManager(array $config, string $expectedUserCheckerClass) + { + $container = $this->getRawContainer(); + $container->register(TestUserChecker::class); + + $container->loadFromExtension('security', [ + 'enable_authenticator_manager' => true, + 'firewalls' => [ + 'main' => array_merge([ + 'pattern' => '/.*', + 'http_basic' => true, + ], $config), + ], + ]); + + $container->compile(); + + $userCheckerId = (string) $container->getDefinition('security.listener.user_checker.main')->getArgument(0); + $this->assertTrue($container->has($userCheckerId)); + $this->assertEquals($expectedUserCheckerClass, $container->findDefinition($userCheckerId)->getClass()); + } + + public function provideUserCheckerConfig() + { + yield [[], UserChecker::class]; + yield [['user_checker' => TestUserChecker::class], TestUserChecker::class]; + } + protected function getRawContainer() { $container = new ContainerBuilder(); @@ -689,3 +722,14 @@ public function supportsRememberMe() { } } + +class TestUserChecker implements UserCheckerInterface +{ + public function checkPreAuth(UserInterface $user) + { + } + + public function checkPostAuth(UserInterface $user) + { + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy