@@ -76,7 +76,54 @@ as the value to the current URL:
7676 .. tip ::
7777
7878 Instead of adding a ``_switch_user `` query string parameter, you can pass
79- the username in a ``HTTP_X_SWITCH_USER `` header.
79+ the username in a custom HTTP header by adjusting the ``parameter `` setting.
80+ For example, to use ``X-Switch-User `` header (available in PHP as
81+ ``HTTP_X_SWITCH_USER ``) add this configuration:
82+
83+ .. configuration-block ::
84+
85+ .. code-block :: yaml
86+
87+ # config/packages/security.yaml
88+ security :
89+ # ...
90+ firewalls :
91+ main :
92+ # ...
93+ switch_user : { parameter: X-Switch-User }
94+
95+ .. code-block :: xml
96+
97+ <!-- config/packages/security.xml -->
98+ <?xml version =" 1.0" encoding =" UTF-8" ?>
99+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
100+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
101+ xmlns : srv =" http://symfony.com/schema/dic/services"
102+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
103+ https://symfony.com/schema/dic/services/services-1.0.xsd
104+ http://symfony.com/schema/dic/security
105+ https://symfony.com/schema/dic/security/security-1.0.xsd" >
106+ <config >
107+ <!-- ... -->
108+ <firewall name =" main" >
109+ <!-- ... -->
110+ <switch-user parameter =" X-Switch-User" />
111+ </firewall >
112+ </config >
113+ </srv : container >
114+
115+ .. code-block :: php
116+
117+ // config/packages/security.php
118+ use Symfony\Config\SecurityConfig;
119+ return static function (SecurityConfig $security) {
120+ // ...
121+ $security->firewall('main')
122+ // ...
123+ ->switchUser()
124+ ->parameter('X-Switch-User')
125+ ;
126+ };
80127
81128 To switch back to the original user, use the special ``_exit `` username:
82129
0 commit comments