Skip to content

Commit a4c9905

Browse files
committed
[SecurityBundle] Don't register deprecated listeners with authenticator manager enabled
1 parent 3b6e566 commit a4c9905

File tree

2 files changed

+121
-118
lines changed

2 files changed

+121
-118
lines changed

Resources/config/security_legacy.php

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

1414
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1515
use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager;
16+
use Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider;
17+
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
18+
use Symfony\Component\Security\Core\Authentication\Provider\LdapBindAuthenticationProvider;
19+
use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider;
20+
use Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener;
21+
use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener;
22+
use Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener;
23+
use Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener;
24+
use Symfony\Component\Security\Http\Firewall\UsernamePasswordJsonAuthenticationListener;
25+
use Symfony\Component\Security\Http\Firewall\X509AuthenticationListener;
1626

1727
return static function (ContainerConfigurator $container) {
1828
$container->services()
@@ -24,6 +34,117 @@
2434
param('security.authentication.manager.erase_credentials'),
2535
])
2636
->call('setEventDispatcher', [service('event_dispatcher')])
37+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
2738
->alias(AuthenticationManagerInterface::class, 'security.authentication.manager')
39+
->deprecate('symfony/security-bundle', '5.3', 'The "%alias_id%" alias is deprecated, use the new authenticator system instead.')
40+
41+
->set('security.authentication.listener.anonymous', AnonymousAuthenticationListener::class)
42+
->args([
43+
service('security.untracked_token_storage'),
44+
abstract_arg('Key'),
45+
service('logger')->nullOnInvalid(),
46+
service('security.authentication.manager'),
47+
])
48+
->tag('monolog.logger', ['channel' => 'security'])
49+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
50+
51+
->set('security.authentication.provider.anonymous', AnonymousAuthenticationProvider::class)
52+
->args([abstract_arg('Key')])
53+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
54+
55+
->set('security.authentication.listener.form', UsernamePasswordFormAuthenticationListener::class)
56+
->parent('security.authentication.listener.abstract')
57+
->abstract()
58+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
59+
60+
->set('security.authentication.listener.x509', X509AuthenticationListener::class)
61+
->abstract()
62+
->args([
63+
service('security.token_storage'),
64+
service('security.authentication.manager'),
65+
abstract_arg('Provider-shared Key'),
66+
abstract_arg('x509 user'),
67+
abstract_arg('x509 credentials'),
68+
service('logger')->nullOnInvalid(),
69+
service('event_dispatcher')->nullOnInvalid(),
70+
])
71+
->tag('monolog.logger', ['channel' => 'security'])
72+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
73+
74+
->set('security.authentication.listener.json', UsernamePasswordJsonAuthenticationListener::class)
75+
->abstract()
76+
->args([
77+
service('security.token_storage'),
78+
service('security.authentication.manager'),
79+
service('security.http_utils'),
80+
abstract_arg('Provider-shared Key'),
81+
abstract_arg('Failure handler'),
82+
abstract_arg('Success Handler'),
83+
[], // Options
84+
service('logger')->nullOnInvalid(),
85+
service('event_dispatcher')->nullOnInvalid(),
86+
service('property_accessor')->nullOnInvalid(),
87+
])
88+
->call('setTranslator', [service('translator')->ignoreOnInvalid()])
89+
->tag('monolog.logger', ['channel' => 'security'])
90+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
91+
92+
->set('security.authentication.listener.remote_user', RemoteUserAuthenticationListener::class)
93+
->abstract()
94+
->args([
95+
service('security.token_storage'),
96+
service('security.authentication.manager'),
97+
abstract_arg('Provider-shared Key'),
98+
abstract_arg('REMOTE_USER server env var'),
99+
service('logger')->nullOnInvalid(),
100+
service('event_dispatcher')->nullOnInvalid(),
101+
])
102+
->tag('monolog.logger', ['channel' => 'security'])
103+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
104+
105+
->set('security.authentication.listener.basic', BasicAuthenticationListener::class)
106+
->abstract()
107+
->args([
108+
service('security.token_storage'),
109+
service('security.authentication.manager'),
110+
abstract_arg('Provider-shared Key'),
111+
abstract_arg('Entry Point'),
112+
service('logger')->nullOnInvalid(),
113+
])
114+
->tag('monolog.logger', ['channel' => 'security'])
115+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
116+
117+
->set('security.authentication.provider.dao', DaoAuthenticationProvider::class)
118+
->abstract()
119+
->args([
120+
abstract_arg('User Provider'),
121+
abstract_arg('User Checker'),
122+
abstract_arg('Provider-shared Key'),
123+
service('security.password_hasher_factory'),
124+
param('security.authentication.hide_user_not_found'),
125+
])
126+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
127+
128+
->set('security.authentication.provider.ldap_bind', LdapBindAuthenticationProvider::class)
129+
->abstract()
130+
->args([
131+
abstract_arg('User Provider'),
132+
abstract_arg('UserChecker'),
133+
abstract_arg('Provider-shared Key'),
134+
abstract_arg('LDAP'),
135+
abstract_arg('Base DN'),
136+
param('security.authentication.hide_user_not_found'),
137+
abstract_arg('search dn'),
138+
abstract_arg('search password'),
139+
])
140+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
141+
142+
->set('security.authentication.provider.pre_authenticated', PreAuthenticatedAuthenticationProvider::class)
143+
->abstract()
144+
->args([
145+
abstract_arg('User Provider'),
146+
abstract_arg('UserChecker'),
147+
])
148+
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
28149
;
29150
};

Resources/config/security_listeners.php

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14-
use Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider;
15-
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
16-
use Symfony\Component\Security\Core\Authentication\Provider\LdapBindAuthenticationProvider;
17-
use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider;
1814
use Symfony\Component\Security\Http\AccessMap;
1915
use Symfony\Component\Security\Http\Authentication\CustomAuthenticationFailureHandler;
2016
use Symfony\Component\Security\Http\Authentication\CustomAuthenticationSuccessHandler;
@@ -27,33 +23,14 @@
2723
use Symfony\Component\Security\Http\EventListener\DefaultLogoutListener;
2824
use Symfony\Component\Security\Http\EventListener\SessionLogoutListener;
2925
use Symfony\Component\Security\Http\Firewall\AccessListener;
30-
use Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener;
31-
use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener;
3226
use Symfony\Component\Security\Http\Firewall\ChannelListener;
3327
use Symfony\Component\Security\Http\Firewall\ContextListener;
3428
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
3529
use Symfony\Component\Security\Http\Firewall\LogoutListener;
36-
use Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener;
3730
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
38-
use Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener;
39-
use Symfony\Component\Security\Http\Firewall\UsernamePasswordJsonAuthenticationListener;
40-
use Symfony\Component\Security\Http\Firewall\X509AuthenticationListener;
4131

4232
return static function (ContainerConfigurator $container) {
4333
$container->services()
44-
->set('security.authentication.listener.anonymous', AnonymousAuthenticationListener::class)
45-
->args([
46-
service('security.untracked_token_storage'),
47-
abstract_arg('Key'),
48-
service('logger')->nullOnInvalid(),
49-
service('security.authentication.manager'),
50-
])
51-
->tag('monolog.logger', ['channel' => 'security'])
52-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
53-
54-
->set('security.authentication.provider.anonymous', AnonymousAuthenticationProvider::class)
55-
->args([abstract_arg('Key')])
56-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
5734

5835
->set('security.authentication.retry_entry_point', RetryAuthenticationEntryPoint::class)
5936
->args([
@@ -160,101 +137,6 @@
160137
])
161138
->tag('monolog.logger', ['channel' => 'security'])
162139

163-
->set('security.authentication.listener.form', UsernamePasswordFormAuthenticationListener::class)
164-
->parent('security.authentication.listener.abstract')
165-
->abstract()
166-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
167-
168-
->set('security.authentication.listener.x509', X509AuthenticationListener::class)
169-
->abstract()
170-
->args([
171-
service('security.token_storage'),
172-
service('security.authentication.manager'),
173-
abstract_arg('Provider-shared Key'),
174-
abstract_arg('x509 user'),
175-
abstract_arg('x509 credentials'),
176-
service('logger')->nullOnInvalid(),
177-
service('event_dispatcher')->nullOnInvalid(),
178-
])
179-
->tag('monolog.logger', ['channel' => 'security'])
180-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
181-
182-
->set('security.authentication.listener.json', UsernamePasswordJsonAuthenticationListener::class)
183-
->abstract()
184-
->args([
185-
service('security.token_storage'),
186-
service('security.authentication.manager'),
187-
service('security.http_utils'),
188-
abstract_arg('Provider-shared Key'),
189-
abstract_arg('Failure handler'),
190-
abstract_arg('Success Handler'),
191-
[], // Options
192-
service('logger')->nullOnInvalid(),
193-
service('event_dispatcher')->nullOnInvalid(),
194-
service('property_accessor')->nullOnInvalid(),
195-
])
196-
->call('setTranslator', [service('translator')->ignoreOnInvalid()])
197-
->tag('monolog.logger', ['channel' => 'security'])
198-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
199-
200-
->set('security.authentication.listener.remote_user', RemoteUserAuthenticationListener::class)
201-
->abstract()
202-
->args([
203-
service('security.token_storage'),
204-
service('security.authentication.manager'),
205-
abstract_arg('Provider-shared Key'),
206-
abstract_arg('REMOTE_USER server env var'),
207-
service('logger')->nullOnInvalid(),
208-
service('event_dispatcher')->nullOnInvalid(),
209-
])
210-
->tag('monolog.logger', ['channel' => 'security'])
211-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
212-
213-
->set('security.authentication.listener.basic', BasicAuthenticationListener::class)
214-
->abstract()
215-
->args([
216-
service('security.token_storage'),
217-
service('security.authentication.manager'),
218-
abstract_arg('Provider-shared Key'),
219-
abstract_arg('Entry Point'),
220-
service('logger')->nullOnInvalid(),
221-
])
222-
->tag('monolog.logger', ['channel' => 'security'])
223-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
224-
225-
->set('security.authentication.provider.dao', DaoAuthenticationProvider::class)
226-
->abstract()
227-
->args([
228-
abstract_arg('User Provider'),
229-
abstract_arg('User Checker'),
230-
abstract_arg('Provider-shared Key'),
231-
service('security.password_hasher_factory'),
232-
param('security.authentication.hide_user_not_found'),
233-
])
234-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
235-
236-
->set('security.authentication.provider.ldap_bind', LdapBindAuthenticationProvider::class)
237-
->abstract()
238-
->args([
239-
abstract_arg('User Provider'),
240-
abstract_arg('UserChecker'),
241-
abstract_arg('Provider-shared Key'),
242-
abstract_arg('LDAP'),
243-
abstract_arg('Base DN'),
244-
param('security.authentication.hide_user_not_found'),
245-
abstract_arg('search dn'),
246-
abstract_arg('search password'),
247-
])
248-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
249-
250-
->set('security.authentication.provider.pre_authenticated', PreAuthenticatedAuthenticationProvider::class)
251-
->abstract()
252-
->args([
253-
abstract_arg('User Provider'),
254-
abstract_arg('UserChecker'),
255-
])
256-
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
257-
258140
->set('security.exception_listener', ExceptionListener::class)
259141
->abstract()
260142
->args([

0 commit comments

Comments
 (0)