@@ -244,6 +244,64 @@ also adjust the query parameter name via the ``parameter`` setting:
244
244
;
245
245
};
246
246
247
+ Redirecting to a specific target route
248
+ --------------------------------------
249
+
250
+ .. versionadded :: 6.2
251
+
252
+ The ``target_route `` configuration option was introduced in Symfony 6.2.
253
+
254
+ This feature allows you to control the redirection targe route via ``target_route ``.
255
+ It works only in a statefull firewall.
256
+
257
+ .. configuration-block ::
258
+
259
+ .. code-block :: yaml
260
+
261
+ # config/packages/security.yaml
262
+ security :
263
+ # ...
264
+
265
+ firewalls :
266
+ main :
267
+ # ...
268
+ switch_user : { target_route: app_user_dashboard }
269
+
270
+ .. code-block :: xml
271
+
272
+ <!-- config/packages/security.xml -->
273
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
274
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
275
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
276
+ xmlns : srv =" http://symfony.com/schema/dic/services"
277
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
278
+ https://symfony.com/schema/dic/services/services-1.0.xsd
279
+ http://symfony.com/schema/dic/security
280
+ https://symfony.com/schema/dic/security/security-1.0.xsd" >
281
+ <config >
282
+ <!-- ... -->
283
+
284
+ <firewall name =" main" >
285
+ <!-- ... -->
286
+ <switch-user target-route =" app_user_dashboard" />
287
+ </firewall >
288
+ </config >
289
+ </srv : container >
290
+
291
+ .. code-block :: php
292
+
293
+ // config/packages/security.php
294
+ use Symfony\Config\SecurityConfig;
295
+
296
+ return static function (SecurityConfig $security) {
297
+ // ...
298
+ $security->firewall('main')
299
+ // ...
300
+ ->switchUser()
301
+ ->targetRoute('app_user_dashboard')
302
+ ;
303
+ };
304
+
247
305
Limiting User Switching
248
306
-----------------------
249
307
0 commit comments