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

Commitfacbbb0

Browse files
committed
Allow configuring a target url when switching user
1 parent9f55837 commitfacbbb0

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

‎security/impersonating_user.rst‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,64 @@ 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+
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:containerxmlns="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+
<firewallname="main">
285+
<!-- ...-->
286+
<switch-usertarget-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+
247305
Limiting User Switching
248306
-----------------------
249307

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp