Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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, []);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added array’s purpose is to reset $authenticators’s key (cf https://www.php.net/manual/en/function.array-map.php#refsect1-function.array-map-returnvalues) so that testConfigureCustomAuthenticator doesn’t fail.

$container
->setDefinition($managerId = 'security.authenticator.manager.'.$id, new ChildDefinition('security.authenticator.manager'))
->replaceArgument(0, $authenticators)
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading