Skip to content

Commit 027d4f0

Browse files
Merge branch '2.3' into 2.5
* 2.3: [SecurityBundle] Firewall providers building - code cleaning [Filesystem] symlink use RealPath instead LinkTarget Fixed the AuthenticationProviderInterface alignment Fixed the proxy-manager version constraint Conflicts: composer.json src/Symfony/Bridge/ProxyManager/composer.json
2 parents 816352f + ad1b56b commit 027d4f0

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
511511
{
512512
$name = $this->getUserProviderId(strtolower($name));
513513

514+
// Doctrine Entity and In-memory DAO provider are managed by factories
514515
foreach ($this->userProviderFactories as $factory) {
515516
$key = str_replace('-', '_', $factory->getKey());
516517

@@ -537,37 +538,12 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
537538

538539
$container
539540
->setDefinition($name, new DefinitionDecorator('security.user.provider.chain'))
540-
->addArgument($providers)
541-
;
542-
543-
return $name;
544-
}
545-
546-
// Doctrine Entity DAO provider
547-
if (isset($provider['entity'])) {
548-
$container
549-
->setDefinition($name, new DefinitionDecorator('security.user.provider.entity'))
550-
->addArgument($provider['entity']['class'])
551-
->addArgument($provider['entity']['property'])
552-
;
541+
->addArgument($providers);
553542

554543
return $name;
555544
}
556545

557-
// In-memory DAO provider
558-
$definition = $container->setDefinition($name, new DefinitionDecorator('security.user.provider.in_memory'));
559-
foreach ($provider['users'] as $username => $user) {
560-
$userId = $name.'_'.$username;
561-
562-
$container
563-
->setDefinition($userId, new DefinitionDecorator('security.user.provider.in_memory.user'))
564-
->setArguments(array($username, (string) $user['password'], $user['roles']))
565-
;
566-
567-
$definition->addMethodCall('createUser', array(new Reference($userId)));
568-
}
569-
570-
return $name;
546+
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
571547
}
572548

573549
private function getUserProviderId($name)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider;
4+
5+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
6+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
9+
class DummyProvider implements UserProviderFactoryInterface
10+
{
11+
public function create(ContainerBuilder $container, $id, $config)
12+
{
13+
14+
}
15+
16+
public function getKey()
17+
{
18+
return 'foo';
19+
}
20+
21+
public function addConfiguration(NodeDefinition $node)
22+
{
23+
24+
}
25+
}

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
1515
use Symfony\Bundle\SecurityBundle\SecurityBundle;
16+
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
@@ -66,6 +67,33 @@ public function testFirewallWithoutAuthenticationListener()
6667
$container->compile();
6768
}
6869

70+
/**
71+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
72+
* @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider
73+
*/
74+
public function testFirewallWithInvalidUserProvider()
75+
{
76+
$container = $this->getRawContainer();
77+
78+
$extension = $container->getExtension('security');
79+
$extension->addUserProviderFactory(new DummyProvider());
80+
81+
$container->loadFromExtension('security', array(
82+
'providers' => array(
83+
'my_foo' => array('foo' => []),
84+
),
85+
86+
'firewalls' => array(
87+
'some_firewall' => array(
88+
'pattern' => '/.*',
89+
'http_basic' => [],
90+
),
91+
),
92+
));
93+
94+
$container->compile();
95+
}
96+
6997
protected function getRawContainer()
7098
{
7199
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)