Skip to content

Commit 9eb3fbb

Browse files
committed
bug #57748 [SecurityBundle] use firewall-specific user checkers when manually logging in users (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [SecurityBundle] use firewall-specific user checkers when manually logging in users | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57706 | License | MIT Commits ------- 22a0789 use firewall-specific user checkers when manually logging in users
2 parents 169055a + 22a0789 commit 9eb3fbb

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
579579

580580
$container->setAlias('security.user_checker.'.$id, new Alias($firewall['user_checker'], false));
581581

582+
$userCheckerLocator = $container->getDefinition('security.user_checker_locator');
583+
$userCheckerLocator->replaceArgument(0, array_merge($userCheckerLocator->getArgument(0), [$id => new ServiceClosureArgument(new Reference('security.user_checker.'.$id))]));
584+
582585
foreach ($this->getSortedFactories() as $factory) {
583586
$key = str_replace('-', '_', $factory->getKey());
584587
if ('custom_authenticators' !== $key && \array_key_exists($key, $firewall)) {

src/Symfony/Bundle/SecurityBundle/Resources/config/security.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Bundle\SecurityBundle\Security\FirewallContext;
2020
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
2121
use Symfony\Bundle\SecurityBundle\Security\LazyFirewallContext;
22+
use Symfony\Component\DependencyInjection\ServiceLocator;
2223
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
2324
use Symfony\Component\Ldap\Security\LdapUserProvider;
2425
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
@@ -88,7 +89,7 @@
8889
'security.authenticator.managers_locator' => service('security.authenticator.managers_locator')->ignoreOnInvalid(),
8990
'request_stack' => service('request_stack'),
9091
'security.firewall.map' => service('security.firewall.map'),
91-
'security.user_checker' => service('security.user_checker'),
92+
'security.user_checker_locator' => service('security.user_checker_locator'),
9293
'security.firewall.event_dispatcher_locator' => service('security.firewall.event_dispatcher_locator'),
9394
'security.csrf.token_manager' => service('security.csrf.token_manager')->ignoreOnInvalid(),
9495
]),
@@ -124,6 +125,8 @@
124125
->args(['none'])
125126

126127
->set('security.user_checker', InMemoryUserChecker::class)
128+
->set('security.user_checker_locator', ServiceLocator::class)
129+
->args([[]])
127130

128131
->set('security.expression_language', ExpressionLanguage::class)
129132
->args([service('cache.security_expression_language')->nullOnInvalid()])

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public function login(UserInterface $user, ?string $authenticatorName = null, ?s
127127

128128
$authenticator = $this->getAuthenticator($authenticatorName, $firewallName);
129129

130-
$this->container->get('security.user_checker')->checkPreAuth($user);
130+
$userCheckerLocator = $this->container->get('security.user_checker_locator');
131+
$userCheckerLocator->get($firewallName)->checkPreAuth($user);
131132

132133
return $this->container->get('security.authenticator.managers_locator')->get($firewallName)->authenticateUser($user, $authenticator, $request, $badges);
133134
}

src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testLogin()
142142
['request_stack', $requestStack],
143143
['security.firewall.map', $firewallMap],
144144
['security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator)],
145-
['security.user_checker', $userChecker],
145+
['security.user_checker_locator', $this->createContainer('main', $userChecker)],
146146
])
147147
;
148148

@@ -188,7 +188,7 @@ public function testLoginReturnsAuthenticatorResponse()
188188
['request_stack', $requestStack],
189189
['security.firewall.map', $firewallMap],
190190
['security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator)],
191-
['security.user_checker', $userChecker],
191+
['security.user_checker_locator', $this->createContainer('main', $userChecker)],
192192
])
193193
;
194194

0 commit comments

Comments
 (0)
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