File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,49 @@ as the value to the current URL:
75
75
.. tip ::
76
76
77
77
Instead of adding a ``_switch_user `` query string parameter, you can pass
78
- the username in a ``HTTP_X_SWITCH_USER `` header.
78
+ the username in a ``HTTP_X_SWITCH_USER `` header. You can use this feature by adjusting the ``parameter `` setting:
79
+
80
+ .. configuration-block ::
81
+
82
+ .. code-block :: yaml
83
+ # config/packages/security.yaml
84
+ security :
85
+ # ...
86
+ firewalls :
87
+ main :
88
+ # ...
89
+ switch_user : { parameter: HTTP_X_SWITCH_USER }
90
+
91
+ .. code-block :: xml
92
+ <!-- config/packages/security.xml -->
93
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
94
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
95
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
96
+ xmlns : srv =" http://symfony.com/schema/dic/services"
97
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
98
+ https://symfony.com/schema/dic/services/services-1.0.xsd
99
+ http://symfony.com/schema/dic/security
100
+ https://symfony.com/schema/dic/security/security-1.0.xsd" >
101
+ <config >
102
+ <!-- ... -->
103
+ <firewall name =" main" >
104
+ <!-- ... -->
105
+ <switch-user parameter =" HTTP_X_SWITCH_USER" />
106
+ </firewall >
107
+ </config >
108
+ </srv : container >
109
+
110
+ .. code-block :: php
111
+ // config/packages/security.php
112
+ use Symfony\Config\SecurityConfig;
113
+ return static function (SecurityConfig $security) {
114
+ // ...
115
+ $security->firewall('main')
116
+ // ...
117
+ ->switchUser()
118
+ ->parameter('HTTP_X_SWITCH_USER')
119
+ ;
120
+ };
79
121
80
122
To switch back to the original user, use the special ``_exit `` username:
81
123
You can’t perform that action at this time.
0 commit comments