8000 minor #37238 [SecurityBundle] Move configuration from XML to PHP (Jud… · symfony/symfony@9a6e727 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a6e727

Browse files
committed
minor #37238 [SecurityBundle] Move configuration from XML to PHP (JudicaelR)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [SecurityBundle] Move configuration from XML to PHP | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | #37186 <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR |- <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch master. --> Move security configuration from XML to PHP for `collectors`, `console` and `guard` Commits ------- 417636f [Security] Move configuration of guard to PHP 79764a9 [Security] Move configuration of console to PHP 2176ed2 [Security] Move configuration of collectors to PHP
2 parents 7838fef + 417636f commit 9a6e727

File tree

7 files changed

+112
-86
lines changed

7 files changed

+112
-86
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Expand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public function load(array $configs, ContainerBuilder $container)
135135
$phpLoader->load('templating_twig.php');
136136
}
137137

138-
$loader->load('collectors.xml');
139-
$loader->load('guard.xml');
138+
$phpLoader->load('collectors.php');
139+
$phpLoader->load('guard.php');
140140

141141
if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) {
142142
$loader->load('security_debug.xml');
@@ -177,7 +177,7 @@ public function load(array $configs, ContainerBuilder $container)
177177
}
178178

179179
if (class_exists(Application::class)) {
180-
$loader->load('console.xml');
180+
$phpLoader->load('console.php');
181181
$container->getDefinition('security.command.user_password_encoder')->replaceArgument(1, array_keys($config['encoders']));
182182
}
183183

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector;
15+
16+
return static function (ContainerConfigurator $container) {
17+
$container->services()
18+
->set('data_collector.security', SecurityDataCollector::class)
19+
->args([
20+
service('security.untracked_token_storage'),
21+
service('security.role_hierarchy'),
22+
service('security.logout_url_generator'),
23+
service('security.access.decision_manager'),
24+
service('security.firewall.map'),
25+
service('debug.security.firewall')->nullOnInvalid(),
26+
])
27+
->tag('data_collector', [
28+
'template' => '@Security/Collector/security.html.twig',
29+
'id' => 'security',
30+
'priority' => 270,
31+
])
32+
;
33+
};

src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
15+
16+
return static function (ContainerConfigurator $container) {
17+
$container->services()
18+
->set('security.command.user_password_encoder', UserPasswordEncoderCommand::class)
19+
->args([
20+
service('security.encoder_factory'),
21+
abstract_arg('encoders user classes'),
22+
])
23+
->tag('console.command', ['command' => 'security:encode-password'])
24+
;
25+
};

src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener;
15+
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
16+
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
17+
18+
return static function (ContainerConfigurator $container) {
19+
$container->services()
20+
->set('security.authentication.guard_handler', GuardAuthenticatorHandler::class)
21+
->args([
22+
service('security.token_storage'),
23+
service('event_dispatcher')->nullOnInvalid(),
24+
abstract_arg('stateless firewall keys'),
25+
])
26+
->call('setSessionAuthenticationStrategy', [service('security.authentication.session_strategy')])
27+
28+
->alias(GuardAuthenticatorHandler::class, 'security.authentication.guard_handler')
29+
30+
->set('security.authentication.provider.guard', GuardAuthenticationProvider::class)
31+
->abstract()
32+
->args([
33+
abstract_arg('Authenticators'),
34+
abstract_arg('User Provider'),
35+
abstract_arg('Provider-shared Key'),
36+
abstract_arg('User Checker'),
37+
service('security.password_encoder'),
38+
])
39+
40+
->set('security.authentication.listener.guard', GuardAuthenticationListener::class)
41+
->abstract()
42+
->args([
43+
service('security.authentication.guard_handler'),
44+
service('security.authentication.manager'),
45+
abstract_arg('Provider-shared Key'),
46+
abstract_arg('Authenticators'),
47+
service('logger')->nullOnInvalid(),
48+
])
49+
->tag('monolog.logger', ['channel' => 'security'])
50+
;
51+
};

src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0