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
This commit is contained in:
commit
76c35089c5
|
@ -72,7 +72,7 @@
|
||||||
"monolog/monolog": "~1.3",
|
"monolog/monolog": "~1.3",
|
||||||
"propel/propel1": "~1.6",
|
"propel/propel1": "~1.6",
|
||||||
"ircmaxell/password-compat": "~1.0",
|
"ircmaxell/password-compat": "~1.0",
|
||||||
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev",
|
"ocramius/proxy-manager": "~0.3.1",
|
||||||
"egulias/email-validator": "~1.2"
|
"egulias/email-validator": "~1.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.3",
|
||||||
"symfony/dependency-injection": "~2.3",
|
"symfony/dependency-injection": "~2.3",
|
||||||
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev"
|
"ocramius/proxy-manager": "~0.3.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/config": "~2.3"
|
"symfony/config": "~2.3"
|
||||||
|
|
|
@ -511,6 +511,7 @@ class SecurityExtension extends Extension
|
||||||
{
|
{
|
||||||
$name = $this->getUserProviderId(strtolower($name));
|
$name = $this->getUserProviderId(strtolower($name));
|
||||||
|
|
||||||
|
// Doctrine Entity and In-memory DAO provider are managed by factories
|
||||||
foreach ($this->userProviderFactories as $factory) {
|
foreach ($this->userProviderFactories as $factory) {
|
||||||
$key = str_replace('-', '_', $factory->getKey());
|
$key = str_replace('-', '_', $factory->getKey());
|
||||||
|
|
||||||
|
@ -537,37 +538,12 @@ class SecurityExtension extends Extension
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->setDefinition($name, new DefinitionDecorator('security.user.provider.chain'))
|
->setDefinition($name, new DefinitionDecorator('security.user.provider.chain'))
|
||||||
->addArgument($providers)
|
->addArgument($providers);
|
||||||
;
|
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doctrine Entity DAO provider
|
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
|
||||||
if (isset($provider['entity'])) {
|
|
||||||
$container
|
|
||||||
->setDefinition($name, new DefinitionDecorator('security.user.provider.entity'))
|
|
||||||
->addArgument($provider['entity']['class'])
|
|
||||||
->addArgument($provider['entity']['property'])
|
|
||||||
;
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In-memory DAO provider
|
|
||||||
$definition = $container->setDefinition($name, new DefinitionDecorator('security.user.provider.in_memory'));
|
|
||||||
foreach ($provider['users'] as $username => $user) {
|
|
||||||
$userId = $name.'_'.$username;
|
|
||||||
|
|
||||||
$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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUserProviderId($name)
|
private function getUserProviderId($name)
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider;
|
||||||
|
|
||||||
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
|
||||||
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
class DummyProvider implements UserProviderFactoryInterface
|
||||||
|
{
|
||||||
|
public function create(ContainerBuilder $container, $id, $config)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKey()
|
||||||
|
{
|
||||||
|
return 'foo';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addConfiguration(NodeDefinition $node)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
||||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||||
|
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
|
class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
@ -66,6 +67,33 @@ class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
$container->compile();
|
$container->compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
|
* @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider
|
||||||
|
*/
|
||||||
|
public function testFirewallWithInvalidUserProvider()
|
||||||
|
{
|
||||||
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
|
$extension = $container->getExtension('security');
|
||||||
|
$extension->addUserProviderFactory(new DummyProvider());
|
||||||
|
|
||||||
|
$container->loadFromExtension('security', array(
|
||||||
|
'providers' => array(
|
||||||
|
'my_foo' => array('foo' => []),
|
||||||
|
),
|
||||||
|
|
||||||
|
'firewalls' => array(
|
||||||
|
'some_firewall' => array(
|
||||||
|
'pattern' => '/.*',
|
||||||
|
'http_basic' => [],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getRawContainer()
|
protected function getRawContainer()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
|
@ -408,7 +408,7 @@ class Filesystem
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_link($file)) {
|
if (is_link($file)) {
|
||||||
$this->symlink($file->getLinkTarget(), $target);
|
$this->symlink($file->getRealPath(), $target);
|
||||||
} elseif (is_dir($file)) {
|
} elseif (is_dir($file)) {
|
||||||
$this->mkdir($target);
|
$this->mkdir($target);
|
||||||
} elseif (is_file($file)) {
|
} elseif (is_file($file)) {
|
||||||
|
|
|
@ -853,6 +853,31 @@ class FilesystemTest extends FilesystemTestCase
|
||||||
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMirrorCopiesRelativeLinkedContents()
|
||||||
|
{
|
||||||
|
$this->markAsSkippedIfSymlinkIsMissing();
|
||||||
|
|
||||||
|
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||||
|
$oldPath = getcwd();
|
||||||
|
|
||||||
|
mkdir($sourcePath.'nested/', 0777, true);
|
||||||
|
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
|
||||||
|
// Note: Create relative symlink
|
||||||
|
chdir($sourcePath);
|
||||||
|
symlink('nested', 'link1');
|
||||||
|
|
||||||
|
chdir($oldPath);
|
||||||
|
|
||||||
|
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
|
$this->assertTrue(is_dir($targetPath));
|
||||||
|
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
|
||||||
|
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
|
$this->assertEquals($sourcePath.'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePathsForIsAbsolutePath
|
* @dataProvider providePathsForIsAbsolutePath
|
||||||
*/
|
*/
|
||||||
|
|
Reference in New Issue