8000 bug #21791 [SecurityBundle] only pass relevant user provider (xabbuh) · rubenrua/symfony@eb750be · GitHub
[go: up one dir, main page]

Skip to content

Commit eb750be

Browse files
committed
bug symfony#21791 [SecurityBundle] only pass relevant user provider (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [SecurityBundle] only pass relevant user provider | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#4498, symfony#12465, symfony#20401, symfony#21737 | License | MIT | Doc PR | There is no need for the context listener to be aware of all the configured user providers. It must only use the provider for the current firewall (the one identified by the context key passed to the constructor) to refresh the user from the session. Commits ------- d97e07f [SecurityBundle] only pass relevant user provider
2 parents 70be4ba + d97e07f commit eb750be

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,6 @@ private function createFirewalls($config, ContainerBuilder $container)
214214
$firewalls = $config['firewalls'];
215215
$providerIds = $this->createUserProviders($config, $container);
216216

217-
// make the ContextListener aware of the configured user providers
218-
$definition = $container->getDefinition('security.context_listener');
219-
$arguments = $definition->getArguments();
220-
$userProviders = array();
221-
foreach ($providerIds as $userProviderId) {
222-
$userProviders[] = new Reference($userProviderId);
223-
}
224-
$arguments[1] = $userProviders;
225-
$definition->setArguments($arguments);
226-
227217
// load firewall map
228218
$mapDef = $container->getDefinition('security.firewall.map');
229219
$map = $authenticationProviders = array();
@@ -288,7 +278,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
288278
$contextKey = $firewall['context'];
289279
}
290280

291-
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
281+
$listeners[] = new Reference($this->createContextListener($container, $contextKey, $defaultProvider));
292282
}
293283

294284
// Logout listener
@@ -371,14 +361,15 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
371361
return array($matcher, $listeners, $exceptionListener);
372362
}
373363

374-
private function createContextListener($container, $contextKey)
364+
private function createContextListener($container, $contextKey, $providerId)
375365
{
376366
if (isset($this->contextListeners[$contextKey])) {
377367
return $this->contextListeners[$contextKey];
378368
}
379369

380370
$listenerId = 'security.context_listener.'.count($this->contextListeners);
381371
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('security.context_listener'));
372+
$listener->replaceArgument(1, array(new Reference($providerId)));
382373
$listener->replaceArgument(2, $contextKey);
383374

384375
return $this->contextListeners[$contextKey] = $listenerId;

0 commit comments

Comments
 (0)
0