Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8a752c3

Browse filesBrowse files
committed
feature #24318 [SecurityBundle] Deprecate ACL related code (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Deprecate ACL related code | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes/no | Fixed tickets | replaces #23811 | License | MIT | Doc PR | todo Needs symfony/acl-bundle#2 Commits ------- e3b7dc5 [SecurityBundle] Deprecate ACL related code
2 parents efdba48 + e3b7dc5 commit 8a752c3
Copy full SHA for 8a752c3

14 files changed

+315
-46
lines changed

‎UPGRADE-3.4.md

Copy file name to clipboardExpand all lines: UPGRADE-3.4.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,11 @@ SecurityBundle
289289
`Doctrine\DBAL\Connection` as first argument. Not passing it is
290290
deprecated and will throw a `TypeError` in 4.0.
291291

292-
* `SetAclCommand::__construct()` now takes an instance of
293-
`Symfony\Component\Security\Acl\Model\MutableAclProviderInterfaceConnection`
294-
as first argument. Not passing it is deprecated and will throw a `TypeError`
295-
in 4.0.
292+
* The `acl:set` command has been deprecated along with the `SetAclCommand` class,
293+
both will be removed in 4.0. Install symfony/acl-bundle instead
294+
295+
* The `init:acl` command has been deprecated along with the `InitAclCommand` class,
296+
both will be removed in 4.0. Install symfony/acl-bundle and use `acl:init` instead
296297

297298
* Added `logout_on_user_change` to the firewall options. This config item will
298299
trigger a logout when the user has changed. Should be set to true to avoid

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,9 @@ SecurityBundle
667667

668668
* `UserPasswordEncoderCommand` does not extend `ContainerAwareCommand` nor implement `ContainerAwareInterface` anymore.
669669

670-
* `InitAclCommand::__construct()` now requires an instance of
671-
`Doctrine\DBAL\Connection` as first argument.
670+
* `InitAclCommand` has been removed. Use `Symfony\Bundle\AclBundle\Command\InitAclCommand` instead
672671

673-
* `SetAclCommand::__construct()` now requires an instance of
674-
`Symfony\Component\Security\Acl\Model\MutableAclProviderInterfaceConnection`
675-
as first argument.
672+
* `SetAclCommand` has been removed. Use `Symfony\Bundle\AclBundle\Command\SetAclCommand` instead
676673

677674
* The firewall option `logout_on_user_change` is now always true, which will
678675
trigger a logout if the user changes between requests.

‎src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ CHANGELOG
88
`VoterInterface` on the class is now deprecated and will be removed in 4.0.
99
* [BC BREAK] `FirewallContext::getListeners()` now returns `\Traversable|array`
1010
* added info about called security listeners in profiler
11-
* `InitAclCommand::__construct()` now takes an instance of
12-
`Doctrine\DBAL\Connection` as first argument
13-
* `SetAclCommand::__construct()` now takes an instance of
14-
`Symfony\Component\Security\Acl\Model\MutableAclProviderInterfaceConnection`
15-
as first argument
1611
* Added `logout_on_user_change` to the firewall options. This config item will
1712
trigger a logout when the user has changed. Should be set to true to avoid
1813
deprecations in the configuration.
1914
* deprecated HTTP digest authentication
15+
* deprecated command `acl:set` along with `SetAclCommand` class
16+
* deprecated command `init:acl` along with `InitAclCommand` class
2017

2118
3.3.0
2219
-----

‎src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Command;
1313

14+
@trigger_error(sprintf('Class "%s" is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Bundle\AclBundle\Command\SetAclCommand instead.', SetAclCommand::class), E_USER_DEPRECATED);
15+
1416
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1517
use Symfony\Component\Console\Input\InputInterface;
18+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1619
use Symfony\Component\Console\Output\OutputInterface;
20+
use Symfony\Component\Console\Style\SymfonyStyle;
1721
use Symfony\Component\Security\Acl\Dbal\Schema;
1822
use Doctrine\DBAL\Connection;
1923
use Doctrine\DBAL\Schema\SchemaException;
@@ -23,7 +27,7 @@
2327
*
2428
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2529
*
26-
* @final since version 3.4
30+
* @deprecated since version 3.4, to be removed in 4.0. See Symfony\Bundle\AclBundle\Command\SetAclCommand instead.
2731
*/
2832
class InitAclCommand extends ContainerAwareCommand
2933
{
@@ -32,15 +36,9 @@ class InitAclCommand extends ContainerAwareCommand
3236
private $connection;
3337
private $schema;
3438

35-
/**
36-
* @param Connection $connection
37-
* @param Schema $schema
38-
*/
3939
public function __construct($connection = null, Schema $schema = null)
4040
{
4141
if (!$connection instanceof Connection) {
42-
@trigger_error(sprintf('%s() expects an instance of "%s" as first argument since version 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, Connection::class), E_USER_DEPRECATED);
43-
4442
parent::__construct($connection);
4543

4644
return;
@@ -54,8 +52,6 @@ public function __construct($connection = null, Schema $schema = null)
5452

5553
/**
5654
* {@inheritdoc}
57-
*
58-
* BC to be removed in 4.0
5955
*/
6056
public function isEnabled()
6157
{
@@ -93,7 +89,8 @@ protected function configure()
9389
*/
9490
protected function execute(InputInterface $input, OutputInterface $output)
9591
{
96-
// BC to be removed in 4.0
92+
(new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output))->warning('Command "init:acl" is deprecated since version 3.4 and will be removed from SecurityBundle in 4.0. Install symfony/acl-bundle and use "acl:init" instead.');
93+
9794
if (null === $this->connection) {
9895
$this->connection = $this->getContainer()->get('security.acl.dbal.connection');
9996
$this->schema = $this->getContainer()->get('security.acl.dbal.schema');

‎src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Command;
1313

14+
@trigger_error(sprintf('Class "%s" is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Bundle\AclBundle\Command\SetAclCommand instead.', SetAclCommand::class), E_USER_DEPRECATED);
15+
1416
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1517
use Symfony\Component\Console\Input\InputArgument;
1618
use Symfony\Component\Console\Input\InputInterface;
1719
use Symfony\Component\Console\Input\InputOption;
20+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1821
use Symfony\Component\Console\Output\OutputInterface;
22+
use Symfony\Component\Console\Style\SymfonyStyle;
1923
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
2024
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
2125
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
@@ -28,7 +32,7 @@
2832
*
2933
* @author Kévin Dunglas <kevin@les-tilleuls.coop>
3034
*
31-
* @final since version 3.4
35+
* @deprecated since version 3.4, to be removed in 4.0. See Symfony\Bundle\AclBundle\Command\SetAclCommand instead.
3236
*/
3337
class SetAclCommand extends ContainerAwareCommand
3438
{
@@ -42,8 +46,6 @@ class SetAclCommand extends ContainerAwareCommand
4246
public function __construct($provider = null)
4347
{
4448
if (!$provider instanceof MutableAclProviderInterface) {
45-
@trigger_error(sprintf('%s() expects an instance of "%s" as first argument since version 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, MutableAclProviderInterface::class), E_USER_DEPRECATED);
46-
4749
parent::__construct($provider);
4850

4951
return;
@@ -56,8 +58,6 @@ public function __construct($provider = null)
5658

5759
/**
5860
* {@inheritdoc}
59-
*
60-
* BC to be removed in 4.0
6161
*/
6262
public function isEnabled()
6363
{
@@ -117,7 +117,8 @@ protected function configure()
117117
*/
118118
protected function execute(InputInterface $input, OutputInterface $output)
119119
{
120-
// BC to be removed in 4.0
120+
(new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output))->warning('Command "acl:set" is deprecated since version 3.4 and will be removed from SecurityBundle in 4.0. Install symfony/acl-bundle to use this command.');
121+
121122
if (null === $this->provider) {
122123
$this->provider = $this->getContainer()->get('security.acl.provider');
123124
}
@@ -192,8 +193,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
192193
/**
193194
* Gets the mask builder.
194195
*
195-
* BC to be removed in 4.0
196-
*
197196
* @return MaskBuilder
198197
*/
199198
protected function getMaskBuilder()

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ private function addAclSection(ArrayNodeDefinition $rootNode)
121121
$rootNode
122122
->children()
123123
->arrayNode('acl')
124+
->setDeprecated('The "security.acl" configuration key is deprecated since version 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.')
124125
->children()
125126
->scalarNode('connection')
126127
->defaultNull()

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+24-7Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
abstract class CompleteConfigurationTest extends TestCase
2424
{
25-
private static $containerCache = array();
26-
2725
abstract protected function getLoader(ContainerBuilder $container);
2826

2927
abstract protected function getFileExtension();
@@ -38,6 +36,20 @@ public function testRolesHierarchy()
3836
), $container->getParameter('security.role_hierarchy.roles'));
3937
}
4038

39+
/**
40+
* @group legacy
41+
* @expectedDeprecation The "security.acl" configuration key is deprecated since version 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.
42+
*/
43+
public function testRolesHierarchyWithAcl()
44+
{
45+
$container = $this->getContainer('container1_with_acl');
46+
$this->assertEquals(array(
47+
'ROLE_ADMIN' => array('ROLE_USER'),
48+
'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'),
49+
'ROLE_REMOTE' => array('ROLE_USER', 'ROLE_ADMIN'),
50+
), $container->getParameter('security.role_hierarchy.roles'));
51+
}
52+
4153
public function testUserProviders()
4254
{
4355
$container = $this->getContainer('container1');
@@ -439,14 +451,22 @@ public function testEncoders()
439451
)), $container->getDefinition('security.encoder_factory.generic')->getArguments());
440452
}
441453

454+
/**
455+
* @group legacy
456+
* @expectedDeprecation The "security.acl" configuration key is deprecated since version 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.
457+
*/
442458
public function testAcl()
443459
{
444-
$container = $this->getContainer('container1');
460+
$container = $this->getContainer('container1_with_acl');
445461

446462
$this->assertTrue($container->hasDefinition('security.acl.dbal.provider'));
447463
$this->assertEquals('security.acl.dbal.provider', (string) $container->getAlias('security.acl.provider'));
448464
}
449465

466+
/**
467+
* @group legacy
468+
* @expectedDeprecation The "security.acl" configuration key is deprecated since version 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.
469+
*/
450470
public function testCustomAclProvider()
451471
{
452472
$container = $this->getContainer('custom_acl_provider');
@@ -546,9 +566,6 @@ protected function getContainer($file)
546566
{
547567
$file = $file.'.'.$this->getFileExtension();
548568

549-
if (isset(self::$containerCache[$file])) {
550-
return self::$containerCache[$file];
551-
}
552569
$container = new ContainerBuilder();
553570
$security = new SecurityExtension();
554571
$container->registerExtension($security);
@@ -561,6 +578,6 @@ protected function getContainer($file)
561578
$container->getCompilerPassConfig()->setRemovingPasses(array());
562579
$container->compile();
563580

564-
return self::$containerCache[$file] = $container;
581+
return $container;
565582
}
566583
}

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
$container->loadFromExtension('security', array(
4-
'acl' => array(),
54
'encoders' => array(
65
'JMS\FooBundle\Entity\User1' => 'plaintext',
76
'JMS\FooBundle\Entity\User2' => array(
+102Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
$container->loadFromExtension('security', array(
4+
'acl' => array(),
5+
'encoders' => array(
6+
'JMS\FooBundle\Entity\User1' => 'plaintext',
7+
'JMS\FooBundle\Entity\User2' => array(
8+
'algorithm' => 'sha1',
9+
'encode_as_base64' => false,
10+
'iterations' => 5,
11+
),
12+
'JMS\FooBundle\Entity\User3' => array(
13+
'algorithm' => 'md5',
14+
),
15+
'JMS\FooBundle\Entity\User4' => array(
16+
'id' => 'security.encoder.foo',
17+
),
18+
'JMS\FooBundle\Entity\User5' => array(
19+
'algorithm' => 'pbkdf2',
20+
'hash_algorithm' => 'sha1',
21+
'encode_as_base64' => false,
22+
'iterations' => 5,
23+
'key_length' => 30,
24+
),
25+
'JMS\FooBundle\Entity\User6' => array(
26+
'algorithm' => 'bcrypt',
27+
'cost' => 15,
28+
),
29+
),
30+
'providers' => array(
31+
'default' => array(
32+
'memory' => array(
33+
'users' => array(
34+
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'),
35+
),
36+
),
37+
),
38+
'digest' => array(
39+
'memory' => array(
40+
'users' => array(
41+
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'),
42+
),
43+
),
44+
),
45+
'basic' => array(
46+
'memory' => array(
47+
'users' => array(
48+
'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'),
49+
'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')),
50+
),
51+
),
52+
),
53+
'service' => array(
54+
'id' => 'user.manager',
55+
),
56+
'chain' => array(
57+
'chain' => array(
58+
'providers' => array('service', 'basic'),
59+
),
60+
),
61+
),
62+
63+
'firewalls' => array(
64+
'simple' => array('pattern' => '/login', 'security' => false),
65+
'secure' => array('stateless' => true,
66+
'http_basic' => true,
67+
'http_digest' => array('secret' => 'TheSecret'),
68+
'form_login' => true,
69+
'anonymous' => true,
70+
'switch_user' => true,
71+
'x509' => true,
72+
'remote_user' => true,
73+
'logout' => true,
74+
'remember_me' => array('secret' => 'TheSecret'),
75+
'user_checker' => null,
76+
),
77+
'host' => array(
78+
'pattern' => '/test',
79+
'host' => 'foo\\.example\\.org',
80+
'methods' => array('GET', 'POST'),
81+
'anonymous' => true,
82+
'http_basic' => true,
83+
),
84+
'with_user_checker' => array(
85+
'user_checker' => 'app.user_checker',
86+
'anonymous' => true,
87+
'http_basic' => true,
88+
),
89+
),
90+
91+
'access_control' => array(
92+
array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')),
93+
array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'),
94+
array('path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"),
95+
),
96+
97+
'role_hierarchy' => array(
98+
'ROLE_ADMIN' => 'ROLE_USER',
99+
'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'),
100+
'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN',
101+
),
102+
));

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
77

88
<config>
9-
<acl />
10-
119
<encoder class="JMS\FooBundle\Entity\User1" algorithm="plaintext" />
1210

1311
<encoder class="JMS\FooBundle\Entity\User2" algorithm="sha1" encode-as-base64="false" iterations="5" />

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.