diff --git a/DependencyInjection/SecurityExtension.php b/DependencyInjection/SecurityExtension.php
index 81c4a8ee..f454b931 100644
--- a/DependencyInjection/SecurityExtension.php
+++ b/DependencyInjection/SecurityExtension.php
@@ -313,8 +313,8 @@ private function createFirewalls(array $config, ContainerBuilder $container): vo
$authenticators[$name] = null;
} else {
$firewallAuthenticatorRefs = [];
- foreach ($firewallAuthenticators as $authenticatorId) {
- $firewallAuthenticatorRefs[$authenticatorId] = new Reference($authenticatorId);
+ foreach ($firewallAuthenticators as $originalAuthenticatorId => $managerAuthenticatorId) {
+ $firewallAuthenticatorRefs[$originalAuthenticatorId] = new Reference($originalAuthenticatorId);
}
$authenticators[$name] = ServiceLocatorTagPass::register($container, $firewallAuthenticatorRefs);
}
@@ -501,7 +501,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
$configuredEntryPoint = $defaultEntryPoint;
// authenticator manager
- $authenticators = array_map(fn ($id) => new Reference($id), $firewallAuthenticationProviders);
+ $authenticators = array_map(fn ($id) => new Reference($id), $firewallAuthenticationProviders, []);
$container
->setDefinition($managerId = 'security.authenticator.manager.'.$id, new ChildDefinition('security.authenticator.manager'))
->replaceArgument(0, $authenticators)
@@ -625,11 +625,11 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
$authenticators = $factory->createAuthenticator($container, $id, $firewall[$key], $userProvider);
if (\is_array($authenticators)) {
foreach ($authenticators as $authenticator) {
- $authenticationProviders[] = $authenticator;
+ $authenticationProviders[$authenticator] = $authenticator;
$entryPoints[] = $authenticator;
}
} else {
- $authenticationProviders[] = $authenticators;
+ $authenticationProviders[$authenticators] = $authenticators;
$entryPoints[$key] = $authenticators;
}
diff --git a/Resources/config/schema/security-1.0.xsd b/Resources/config/schema/security-1.0.xsd
index ef10635e..a8623e0b 100644
--- a/Resources/config/schema/security-1.0.xsd
+++ b/Resources/config/schema/security-1.0.xsd
@@ -137,7 +137,6 @@
-
@@ -254,14 +253,6 @@
-
-
-
-
-
-
-
-
diff --git a/Tests/DependencyInjection/SecurityExtensionTest.php b/Tests/DependencyInjection/SecurityExtensionTest.php
index c4ae38e6..d0f3549a 100644
--- a/Tests/DependencyInjection/SecurityExtensionTest.php
+++ b/Tests/DependencyInjection/SecurityExtensionTest.php
@@ -924,6 +924,10 @@ public function testAuthenticatorsDecoration()
$this->assertSame('debug.'.TestAuthenticator::class, (string) reset($managerAuthenticators), 'AuthenticatorManager must be injected traceable authenticators in debug mode.');
$this->assertTrue($container->hasDefinition(TestAuthenticator::class), 'Original authenticator must still exist in the container so it can be used outside of the AuthenticatorManager’s context.');
+
+ $securityHelperAuthenticatorLocator = $container->getDefinition($container->getDefinition('security.helper')->getArgument(1)['main']);
+ $this->assertArrayHasKey(TestAuthenticator::class, $authenticatorMap = $securityHelperAuthenticatorLocator->getArgument(0), 'When programmatically authenticating a user, authenticators’ name must be their original ID.');
+ $this->assertSame(TestAuthenticator::class, (string) $authenticatorMap[TestAuthenticator::class]->getValues()[0], 'When programmatically authenticating a user, original authenticators must be used.');
}
protected function getRawContainer()