Skip to content

Commit a93196b

Browse files
committed
fix(security): user login programmatically with dedicated user checker on a firewall
1 parent e49f84b commit a93196b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
'request_stack' => service('request_stack'),
8989
'security.firewall.map' => service('security.firewall.map'),
9090
'security.user_checker' => service('security.user_checker'),
91+
'security.user_checker.main' => service('security.user_checker.main'), // make this dynamic depending on firewalls
9192
'security.firewall.event_dispatcher_locator' => service('security.firewall.event_dispatcher_locator'),
9293
'security.csrf.token_manager' => service('security.csrf.token_manager')->ignoreOnInvalid(),
9394
]),

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ public function login(UserInterface $user, ?string $authenticatorName = null, ?s
9696

9797
$authenticator = $this->getAuthenticator($authenticatorName, $firewallName);
9898

99-
$this->container->get('security.user_checker')->checkPreAuth($user);
99+
100+
if ($this->container->has('security.user_checker.'.$firewallName)) {
101+
$this->container->get('security.user_checker.'.$firewallName)->checkPreAuth($user);
102+
} else {
103+
$this->container->get('security.user_checker')->checkPreAuth($user);
104+
}
100105

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

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