Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0eb0ae5

Browse files
bug #49446 [SecurityBundle] Fix Security::login() on specific firewall (chalasr)
This PR was merged into the 6.2 branch. Discussion ---------- [SecurityBundle] Fix `Security::login()` on specific firewall | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #49444 | License | MIT | Doc PR | - Commits ------- f7043db [SecurityBundle] Fix `Security::login()` on specific firewall
2 parents 49092e3 + f7043db commit 0eb0ae5

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
service_locator([
8484
'security.token_storage' => service('security.token_storage'),
8585
'security.authorization_checker' => service('security.authorization_checker'),
86-
'security.user_authenticator' => service('security.user_authenticator')->ignoreOnInvalid(),
86+
'security.authenticator.managers_locator' => service('security.authenticator.managers_locator')->ignoreOnInvalid(),
8787
'request_stack' => service('request_stack'),
8888
'security.firewall.map' => service('security.firewall.map'),
8989
'security.user_checker' => service('security.user_checker'),

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function login(UserInterface $user, string $authenticatorName = null, str
6969
$authenticator = $this->getAuthenticator($authenticatorName, $firewallName);
7070

7171
$this->container->get('security.user_checker')->checkPreAuth($user);
72-
$this->container->get('security.user_authenticator')->authenticateUser($user, $authenticator, $request);
72+
$this->container->get('security.authenticator.managers_locator')->get($firewallName)->authenticateUser($user, $authenticator, $request);
7373
}
7474

7575
/**

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ security:
4040
custom_authenticators:
4141
- 'Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AuthenticatorBundle\ApiAuthenticator'
4242
provider: main
43+
second:
44+
pattern: ^/second
45+
form_login:
46+
check_path: /second/login/check
47+
custom_authenticators:
48+
- 'Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AuthenticatorBundle\ApiAuthenticator'
49+
provider: main
4350

4451
access_control:
4552
- { path: '^/main/login/check$', roles: IS_AUTHENTICATED_FULLY }
4653
- { path: '^/main/logged-in$', roles: IS_AUTHENTICATED_FULLY }
54+
- { path: '^/second/login/check$', roles: IS_AUTHENTICATED_FULLY }
55+
- { path: '^/second/logged-in$', roles: IS_AUTHENTICATED_FULLY }

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/routing.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ logged-in:
99
force-logout:
1010
path: /main/force-logout
1111
controller: Symfony\Bundle\SecurityBundle\Tests\Functional\LogoutController::logout
12+
13+
second-force-login:
14+
path: /second/force-login
15+
controller: Symfony\Bundle\SecurityBundle\Tests\Functional\ForceLoginController::welcome
16+
17+
second-logged-in:
18+
path: /second/logged-in
19+
controller: Symfony\Bundle\SecurityBundle\Tests\Functional\LoggedInController

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testLogin()
141141
->willReturnMap([
142142
['request_stack', $requestStack],
143143
['security.firewall.map', $firewallMap],
144-
['security.user_authenticator', $userAuthenticator],
144+
['security.authenticator.managers_locator', new ServiceLocator(['main' => fn () => $userAuthenticator])],
145145
['security.user_checker', $userChecker],
146146
])
147147
;

0 commit comments

Comments
 (0)