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

Commit90dc3c8

Browse files
94nonijaviereguiluz
authored andcommitted
[Security] Allow configuring a target url when switching user
1 parent9f55837 commit90dc3c8

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

‎security/impersonating_user.rst‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,67 @@ also adjust the query parameter name via the ``parameter`` setting:
244244
;
245245
};
246246
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+
..note::
255+
256+
It works only in a stateful firewall.
257+
258+
This feature allows you to control the redirection target route via ``target_route``.
259+
260+
..configuration-block::
261+
262+
..code-block::yaml
263+
264+
# config/packages/security.yaml
265+
security:
266+
# ...
267+
268+
firewalls:
269+
main:
270+
# ...
271+
switch_user:{ target_route: app_user_dashboard }
272+
273+
..code-block::xml
274+
275+
<!-- config/packages/security.xml-->
276+
<?xml version="1.0" encoding="UTF-8" ?>
277+
<srv:containerxmlns="http://symfony.com/schema/dic/security"
278+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
279+
xmlns:srv="http://symfony.com/schema/dic/services"
280+
xsi:schemaLocation="http://symfony.com/schema/dic/services
281+
https://symfony.com/schema/dic/services/services-1.0.xsd
282+
http://symfony.com/schema/dic/security
283+
https://symfony.com/schema/dic/security/security-1.0.xsd">
284+
<config>
285+
<!-- ...-->
286+
287+
<firewallname="main">
288+
<!-- ...-->
289+
<switch-usertarget-route="app_user_dashboard"/>
290+
</firewall>
291+
</config>
292+
</srv:container>
293+
294+
..code-block::php
295+
296+
// config/packages/security.php
297+
use Symfony\Config\SecurityConfig;
298+
299+
return static function (SecurityConfig $security) {
300+
// ...
301+
$security->firewall('main')
302+
// ...
303+
->switchUser()
304+
->targetRoute('app_user_dashboard')
305+
;
306+
};
307+
247308
Limiting User Switching
248309
-----------------------
249310

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp