[SecurityBundle] Don't register in memory users as services
This commit is contained in:
parent
78a8a63450
commit
13fa0454e4
@ -14,7 +14,6 @@ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvide
|
|||||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InMemoryFactory creates services for the memory provider.
|
* InMemoryFactory creates services for the memory provider.
|
||||||
@ -27,17 +26,13 @@ class InMemoryFactory implements UserProviderFactoryInterface
|
|||||||
public function create(ContainerBuilder $container, $id, $config)
|
public function create(ContainerBuilder $container, $id, $config)
|
||||||
{
|
{
|
||||||
$definition = $container->setDefinition($id, new DefinitionDecorator('security.user.provider.in_memory'));
|
$definition = $container->setDefinition($id, new DefinitionDecorator('security.user.provider.in_memory'));
|
||||||
|
$users = array();
|
||||||
|
|
||||||
foreach ($config['users'] as $username => $user) {
|
foreach ($config['users'] as $username => $user) {
|
||||||
$userId = $id.'_'.$username;
|
$users[$username] = array('password' => (string) $user['password'], 'roles' => $user['roles']);
|
||||||
|
|
||||||
$container
|
|
||||||
->setDefinition($userId, new DefinitionDecorator('security.user.provider.in_memory.user'))
|
|
||||||
->setArguments(array($username, (string) $user['password'], $user['roles']))
|
|
||||||
;
|
|
||||||
|
|
||||||
$definition->addMethodCall('createUser', array(new Reference($userId)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$definition->addArgument($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKey()
|
public function getKey()
|
||||||
|
@ -44,12 +44,8 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
|
|
||||||
$expectedProviders = array(
|
$expectedProviders = array(
|
||||||
'security.user.provider.concrete.default',
|
'security.user.provider.concrete.default',
|
||||||
'security.user.provider.concrete.default_foo',
|
|
||||||
'security.user.provider.concrete.digest',
|
'security.user.provider.concrete.digest',
|
||||||
'security.user.provider.concrete.digest_foo',
|
|
||||||
'security.user.provider.concrete.basic',
|
'security.user.provider.concrete.basic',
|
||||||
'security.user.provider.concrete.basic_foo',
|
|
||||||
'security.user.provider.concrete.basic_bar',
|
|
||||||
'security.user.provider.concrete.service',
|
'security.user.provider.concrete.service',
|
||||||
'security.user.provider.concrete.chain',
|
'security.user.provider.concrete.chain',
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user