diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 5f44a7fad23..67b76c7b70a 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -75,7 +75,52 @@ as the value to the current URL: .. tip:: Instead of adding a ``_switch_user`` query string parameter, you can pass - the username in a ``HTTP_X_SWITCH_USER`` header. + the username in a ``HTTP_X_SWITCH_USER`` header. You can use this feature by adjusting the ``parameter`` setting: + + .. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + # ... + firewalls: + main: + # ... + switch_user: { parameter: HTTP_X_SWITCH_USER } + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + return static function (SecurityConfig $security) { + // ... + $security->firewall('main') + // ... + ->switchUser() + ->parameter('HTTP_X_SWITCH_USER') + ; + }; To switch back to the original user, use the special ``_exit`` username: