[SecurityBundle] Fix switch_user provider configuration handling
This commit is contained in:
parent
f75e9d583c
commit
417169b745
@ -681,7 +681,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
return $exceptionListenerId;
|
||||
}
|
||||
|
||||
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless): string
|
||||
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, ?string $defaultProvider, bool $stateless): string
|
||||
{
|
||||
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;
|
||||
|
||||
|
@ -390,6 +390,30 @@ class SecurityExtensionTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function testSwitchUserWithSeveralDefinedProvidersButNoFirewallRootProviderConfigured()
|
||||
{
|
||||
$container = $this->getRawContainer();
|
||||
$container->loadFromExtension('security', [
|
||||
'providers' => [
|
||||
'first' => ['id' => 'foo'],
|
||||
'second' => ['id' => 'bar'],
|
||||
],
|
||||
|
||||
'firewalls' => [
|
||||
'foobar' => [
|
||||
'switch_user' => [
|
||||
'provider' => 'second',
|
||||
],
|
||||
'anonymous' => true,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertEquals(new Reference('security.user.provider.concrete.second'), $container->getDefinition('security.authentication.switchuser_listener.foobar')->getArgument(1));
|
||||
}
|
||||
|
||||
protected function getRawContainer()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
Reference in New Issue
Block a user