From 90dc3c8a720a3f2e61a044fe750c50b36b945868 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Thu, 21 Jul 2022 09:24:50 +0200 Subject: [PATCH] [Security] Allow configuring a target url when switching user --- security/impersonating_user.rst | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 3219802edb7..b51a96d6fec 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -244,6 +244,67 @@ also adjust the query parameter name via the ``parameter`` setting: ; }; +Redirecting to a Specific Target Route +-------------------------------------- + +.. versionadded:: 6.2 + + The ``target_route`` configuration option was introduced in Symfony 6.2. + +.. note:: + + It works only in a stateful firewall. + +This feature allows you to control the redirection target route via ``target_route``. + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + # ... + + firewalls: + main: + # ... + switch_user: { target_route: app_user_dashboard } + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + // ... + $security->firewall('main') + // ... + ->switchUser() + ->targetRoute('app_user_dashboard') + ; + }; + Limiting User Switching -----------------------