Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitcdfd498

Browse files
committed
[Security] Deprecate the old authentication mechanisms
1 parent10ced7a commitcdfd498

File tree

173 files changed

+1957
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+1957
-134
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public function getConfigTreeBuilder()
8383
return$v;
8484
})
8585
->end()
86+
->beforeNormalization()
87+
->ifTrue(function ($v) {
88+
return !($v['enable_authenticator_manager'] ??false);
89+
})
90+
->then(function ($v) {
91+
trigger_deprecation('symfony/security-bundle','5.3','Not setting the "security.enable_authenticator_manager" config option to true is deprecated.');
92+
93+
return$v;
94+
})
95+
->end()
8696
->children()
8797
->scalarNode('access_denied_url')->defaultNull()->example('/foo/error403')->end()
8898
->enumNode('session_fixation_strategy')

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AnonymousFactory.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* @author Wouter de Jong <wouter@wouterj.nl>
2222
*
2323
* @internal
24+
*
25+
* @deprecated since Symfony 5.3, use the new authenticator system instead
2426
*/
2527
class AnonymousFactoryimplements SecurityFactoryInterface, AuthenticatorFactoryInterface
2628
{

‎src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.php‎

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

1414
useSymfony\Bundle\SecurityBundle\Security\UserAuthenticator;
1515
useSymfony\Component\DependencyInjection\ServiceLocator;
16-
useSymfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1716
useSymfony\Component\Security\Http\Authentication\AuthenticatorManager;
1817
useSymfony\Component\Security\Http\Authentication\NoopAuthenticationManager;
1918
useSymfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
@@ -60,7 +59,9 @@
6059
->alias(UserAuthenticatorInterface::class,'security.user_authenticator')
6160

6261
->set('security.authentication.manager', NoopAuthenticationManager::class)
63-
->alias(AuthenticationManagerInterface::class,'security.authentication.manager')
62+
->alias('AuthenticationManagerInterface::class','security.authentication.manager')
63+
->deprecate('symfony/security-bundle','5.3','The "%alias_id%" alias is deprecated.')
64+
6465

6566
->set('security.firewall.authenticator', AuthenticatorManagerListener::class)
6667
->abstract()

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

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,127 @@ public function testFirewalls()
127127
$configs[0][2] =strtolower($configs[0][2]);
128128
$configs[2][2] =strtolower($configs[2][2]);
129129

130+
$this->assertEquals([
131+
[
132+
'simple',
133+
'security.user_checker',
134+
'.security.request_matcher.xmi9dcw',
135+
false,
136+
false,
137+
'',
138+
'',
139+
'',
140+
'',
141+
'',
142+
[],
143+
null,
144+
],
145+
[
146+
'secure',
147+
'security.user_checker',
148+
null,
149+
true,
150+
true,
151+
'security.user.provider.concrete.default',
152+
null,
153+
'security.authenticator.form_login.secure',
154+
null,
155+
null,
156+
[
157+
'switch_user',
158+
'x509',
159+
'remote_user',
160+
'form_login',
161+
'http_basic',
162+
'remember_me',
163+
],
164+
[
165+
'parameter' =>'_switch_user',
166+
'role' =>'ROLE_ALLOWED_TO_SWITCH',
167+
],
168+
],
169+
[
170+
'host',
171+
'security.user_checker',
172+
'.security.request_matcher.iw4hyjb',
173+
true,
174+
false,
175+
'security.user.provider.concrete.default',
176+
'host',
177+
'security.authenticator.http_basic.host',
178+
null,
179+
null,
180+
[
181+
'http_basic',
182+
],
183+
null,
184+
],
185+
[
186+
'with_user_checker',
187+
'app.user_checker',
188+
null,
189+
true,
190+
false,
191+
'security.user.provider.concrete.default',
192+
'with_user_checker',
193+
'security.authenticator.http_basic.with_user_checker',
194+
null,
195+
null,
196+
[
197+
'http_basic',
198+
],
199+
null,
200+
],
201+
],$configs);
202+
203+
$this->assertEquals([
204+
[],
205+
[
206+
'security.channel_listener',
207+
'security.firewall.authenticator.secure',
208+
'security.authentication.switchuser_listener.secure',
209+
'security.access_listener',
210+
],
211+
[
212+
'security.channel_listener',
213+
'security.context_listener.0',
214+
'security.firewall.authenticator.host',
215+
'security.access_listener',
216+
],
217+
[
218+
'security.channel_listener',
219+
'security.context_listener.1',
220+
'security.firewall.authenticator.with_user_checker',
221+
'security.access_listener',
222+
],
223+
],$listeners);
224+
225+
$this->assertFalse($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface','No user checker alias is registered when custom user checker services are registered'));
226+
}
227+
228+
/**
229+
* @group legacy
230+
*/
231+
publicfunctiontestLegacyFirewalls()
232+
{
233+
$container =$this->getContainer('legacy_container1');
234+
$arguments =$container->getDefinition('security.firewall.map')->getArguments();
235+
$listeners = [];
236+
$configs = [];
237+
foreach (array_keys($arguments[1]->getValues())as$contextId) {
238+
$contextDef =$container->getDefinition($contextId);
239+
$arguments =$contextDef->getArguments();
240+
$listeners[] =array_map('strval',$arguments[0]->getValues());
241+
242+
$configDef =$container->getDefinition((string)$arguments[3]);
243+
$configs[] =array_values($configDef->getArguments());
244+
}
245+
246+
// the IDs of the services are case sensitive or insensitive depending on
247+
// the Symfony version. Transform them to lowercase to simplify tests.
248+
$configs[0][2] =strtolower($configs[0][2]);
249+
$configs[2][2] =strtolower($configs[2][2]);
250+
130251
$this->assertEquals([
131252
[
132253
'simple',
@@ -881,15 +1002,21 @@ public function testHashersWithBCrypt()
8811002
]],$container->getDefinition('security.password_hasher_factory')->getArguments());
8821003
}
8831004

884-
publicfunctiontestRememberMeThrowExceptionsDefault()
1005+
/**
1006+
* @group legacy
1007+
*/
1008+
publicfunctiontestLegacyRememberMeThrowExceptionsDefault()
8851009
{
886-
$container =$this->getContainer('container1');
1010+
$container =$this->getContainer('legacy_container1');
8871011
$this->assertTrue($container->getDefinition('security.authentication.listener.rememberme.secure')->getArgument(5));
8881012
}
8891013

890-
publicfunctiontestRememberMeThrowExceptions()
1014+
/**
1015+
* @group legacy
1016+
*/
1017+
publicfunctiontestLegacyRememberMeThrowExceptions()
8911018
{
892-
$container =$this->getContainer('remember_me_options');
1019+
$container =$this->getContainer('legacy_remember_me_options');
8931020
$service =$container->getDefinition('security.authentication.listener.rememberme.main');
8941021
$this->assertEquals('security.authentication.rememberme.services.persistent.main',$service->getArgument(1));
8951022
$this->assertFalse($service->getArgument(5));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
$container->loadFromExtension('security', [
4+
'enable_authenticator_manager' =>true,
45
'access_decision_manager' => [
56
'allow_if_all_abstain' =>true,
67
'allow_if_equal_granted_denied' =>false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
$container->loadFromExtension('security', [
4+
'enable_authenticator_manager' =>true,
45
'providers' => [
56
'default' => [
67
'memory' => [

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
$container->loadFromExtension('security', [
4+
'enable_authenticator_manager' =>true,
45
'access_decision_manager' => [
56
'service' =>'app.access_decision_manager',
67
],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
$container->loadFromExtension('security', [
4+
'enable_authenticator_manager' =>true,
45
'access_decision_manager' => [
56
'service' =>'app.access_decision_manager',
67
'strategy' =>'affirmative',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
$this->load('container1.php');
44

55
$container->loadFromExtension('security', [
6+
'enable_authenticator_manager' =>true,
67
'password_hashers' => [
78
'JMS\FooBundle\Entity\User7' => [
89
'algorithm' =>'argon2i',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
$this->load('container1.php');
44

55
$container->loadFromExtension('security', [
6+
'enable_authenticator_manager' =>true,
67
'password_hashers' => [
78
'JMS\FooBundle\Entity\User7' => [
89
'algorithm' =>'bcrypt',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp