Skip to content

Commit 4ec3cda

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: be explicit about the signal to reset fix Finder test using the ftp wrapper by switching the server being used use firewall-specific user checkers when manually logging in users
2 parents a674637 + c9a134c commit 4ec3cda

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

DependencyInjection/SecurityExtension.php

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

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

566+
$userCheckerLocator = $container->getDefinition('security.user_checker_locator');
567+
$userCheckerLocator->replaceArgument(0, array_merge($userCheckerLocator->getArgument(0), [$id => new ServiceClosureArgument(new Reference('security.user_checker.'.$id))]));
568+
566569
foreach ($this->getSortedFactories() as $factory) {
567570
$key = str_replace('-', '_', $factory->getKey());
568571
if ('custom_authenticators' !== $key && \array_key_exists($key, $firewall)) {

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;
@@ -87,7 +88,7 @@
8788
'security.authenticator.managers_locator' => service('security.authenticator.managers_locator')->ignoreOnInvalid(),
8889
'request_stack' => service('request_stack'),
8990
'security.firewall.map' => service('security.firewall.map'),
90-
'security.user_checker' => service('security.user_checker'),
91+
'security.user_checker_locator' => service('security.user_checker_locator'),
9192
'security.firewall.event_dispatcher_locator' => service('security.firewall.event_dispatcher_locator'),
9293
'security.csrf.token_manager' => service('security.csrf.token_manager')->ignoreOnInvalid(),
9394
]),
@@ -121,6 +122,8 @@
121122
->args(['none'])
122123

123124
->set('security.user_checker', InMemoryUserChecker::class)
125+
->set('security.user_checker_locator', ServiceLocator::class)
126+
->args([[]])
124127

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

Security.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ 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+
$userCheckerLocator = $this->container->get('security.user_checker_locator');
100+
$userCheckerLocator->get($firewallName)->checkPreAuth($user);
100101

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

Tests/SecurityTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function testLogin()
140140
$container->set('request_stack', $requestStack);
141141
$container->set('security.firewall.map', $firewallMap);
142142
$container->set('security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator));
143-
$container->set('security.user_checker', $userChecker);
143+
$container->set('security.user_checker_locator', $this->createContainer('main', $userChecker));
144144

145145
$firewallMap->expects($this->once())->method('getFirewallConfig')->willReturn($firewall);
146146
$userAuthenticator->expects($this->once())->method('authenticateUser')->with($user, $authenticator, $request);
@@ -180,7 +180,7 @@ public function testLoginReturnsAuthenticatorResponse()
180180
$container->set('request_stack', $requestStack);
181181
$container->set('security.firewall.map', $firewallMap);
182182
$container->set('security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator));
183-
$container->set('security.user_checker', $userChecker);
183+
$container->set('security.user_checker_locator', $this->createContainer('main', $userChecker));
184184

185185
$firewallMap->expects($this->once())->method('getFirewallConfig')->willReturn($firewall);
186186
$userChecker->expects($this->once())->method('checkPreAuth')->with($user);

0 commit comments

Comments
 (0)