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