Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d6a3fe

Browse filesBrowse files
committed
[Security][Guard] Lazy load authenticators
1 parent bcf8b68 commit 1d6a3fe
Copy full SHA for 1d6a3fe

File tree

4 files changed

+10
-6
lines changed
Filter options

4 files changed

+10
-6
lines changed

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ChildDefinition;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1819

1920
/**
2021
* Configures the "guard" authentication provider key under a firewall.
@@ -62,11 +63,13 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
6263
$authenticatorReferences[] = new Reference($authenticatorId);
6364
}
6465

66+
$authenticators = new IteratorArgument($authenticatorReferences);
67+
6568
// configure the GuardAuthenticationFactory to have the dynamic constructor arguments
6669
$providerId = 'security.authentication.provider.guard.'.$id;
6770
$container
6871
->setDefinition($providerId, new ChildDefinition('security.authentication.provider.guard'))
69-
->replaceArgument(0, $authenticatorReferences)
72+
->replaceArgument(0, $authenticators)
7073
->replaceArgument(1, new Reference($userProvider))
7174
->replaceArgument(2, $id)
7275
->replaceArgument(3, new Reference('security.user_checker.'.$id))
@@ -76,7 +79,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
7679
$listenerId = 'security.authentication.listener.guard.'.$id;
7780
$listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.guard'));
7881
$listener->replaceArgument(2, $id);
79-
$listener->replaceArgument(3, $authenticatorReferences);
82+
$listener->replaceArgument(3, $authenticators);
8083

8184
// determine the entryPointId to use
8285
$entryPointId = $this->determineEntryPoint($defaultEntryPoint, $config);

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
1515
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Reference;
1819

@@ -106,15 +107,15 @@ public function testBasicCreate()
106107

107108
$providerDefinition = $container->getDefinition('security.authentication.provider.guard.my_firewall');
108109
$this->assertEquals(array(
109-
'index_0' => array(new Reference('authenticator123')),
110+
'index_0' => new IteratorArgument(array(new Reference('authenticator123'))),
110111
'index_1' => new Reference('my_user_provider'),
111112
'index_2' => 'my_firewall',
112113
'index_3' => new Reference('security.user_checker.my_firewall'),
113114
), $providerDefinition->getArguments());
114115

115116
$listenerDefinition = $container->getDefinition('security.authentication.listener.guard.my_firewall');
116117
$this->assertEquals('my_firewall', $listenerDefinition->getArgument(2));
117-
$this->assertEquals(array(new Reference('authenticator123')), $listenerDefinition->getArgument(3));
118+
$this->assertEquals(array(new Reference('authenticator123')), $listenerDefinition->getArgument(3)->getValues());
118119
}
119120

120121
public function testExistingDefaultEntryPointUsed()

‎src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GuardAuthenticationListener implements ListenerInterface
4545
* @param GuardAuthenticatorInterface[] $guardAuthenticators The authenticators, with keys that match what's passed to GuardAuthenticationProvider
4646
* @param LoggerInterface $logger A LoggerInterface instance
4747
*/
48-
public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, $providerKey, array $guardAuthenticators, LoggerInterface $logger = null)
48+
public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, $providerKey, $guardAuthenticators, LoggerInterface $logger = null)
4949
{
5050
if (empty($providerKey)) {
5151
throw new \InvalidArgumentException('$providerKey must not be empty.');

‎src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface
4545
* @param string $providerKey The provider (i.e. firewall) key
4646
* @param UserCheckerInterface $userChecker
4747
*/
48-
public function __construct(array $guardAuthenticators, UserProviderInterface $userProvider, $providerKey, UserCheckerInterface $userChecker)
48+
public function __construct($guardAuthenticators, UserProviderInterface $userProvider, $providerKey, UserCheckerInterface $userChecker)
4949
{
5050
$this->guardAuthenticators = $guardAuthenticators;
5151
$this->userProvider = $userProvider;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.