Skip to content

Commit 8c47a9f

Browse files
committed
bug symfony#10095 [Security] fix DI for SimpleFormAuthenticationListener (Tobion)
This PR was merged into the 2.4 branch. Discussion ---------- [Security] fix DI for SimpleFormAuthenticationListener | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#10093 | License | MIT | Doc PR | - The problematic commit was symfony@f2f15f5 Commits ------- b3f5fa9 [Security] fix DI for SimpleFormAuthenticationListener
2 parents 2ccb868 + b3f5fa9 commit 8c47a9f

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ protected function createListener($container, $id, $config, $userProvider)
7575
{
7676
$listenerId = parent::createListener($container, $id, $config, $userProvider);
7777

78-
if (isset($config['csrf_provider'])) {
79-
$container
80-
->getDefinition($listenerId)
81-
->addArgument(new Reference($config['csrf_provider']))
82-
;
83-
}
78+
$container
79+
->getDefinition($listenerId)
80+
->addArgument(isset($config['csrf_provider']) ? new Reference($config['csrf_provider']) : null)
81+
;
8482

8583
return $listenerId;
8684
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
6363
protected function createListener($container, $id, $config, $userProvider)
6464
{
6565
$listenerId = parent::createListener($container, $id, $config, $userProvider);
66-
$listener = $container->getDefinition($listenerId);
67-
68-
if (!isset($config['csrf_token_generator'])) {
69-
$listener->addArgument(null);
70-
}
7166

7267
$simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id;
7368
$simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new DefinitionDecorator('security.authentication.simple_success_failure_handler'));
7469
$simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator']));
7570
$simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id)));
7671
$simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id)));
7772

73+
$listener = $container->getDefinition($listenerId);
7874
$listener->replaceArgument(5, new Reference($simpleAuthHandlerId));
7975
$listener->replaceArgument(6, new Reference($simpleAuthHandlerId));
8076
$listener->addArgument(new Reference($config['authenticator']));

0 commit comments

Comments
 (0)