-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Impersonate user header doesn't work #39907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you create a small example application that allows to reproduce your issue? |
Do you get any errors or log entries? |
the implement seems to expect a |
@stof @OskarStark |
In your security.yaml you can do it: main:
pattern: ^/
switch_user:
parameter: 'HTTP_X_SWITCH_USER' In the listener there is: (Symfony\Component\Security\Http\Firewall\SwitchUserListener) $username = $request->get($this->usernameParameter);
if (null === $username || '' === $username) {
$username = $request->headers->get($this->usernameParameter);
} why not do something close to that (to comply with the doc): $username = $request->get($this->usernameParameter);
if (null === $username || '' === $username) {
$username = $request->headers->get($this->usernameParameter, $request->headers->get('HTTP_X_SWITCH_USER'));
} |
The documentation is weird on this point. As Which translate to If you configure I used to configure |
yep, works for me too if, in my config :
PS : If you use nelmios_cors, think to update the config too :
|
Hi there! Is someone willing to submit a pull request to the documentation to add the small configuration example shared by @Gu3 in the header tip? |
closing here as this rather looks like a documentation issue |
To use switching user feature via `HTTP_X_SWITCH_USER` header we have to set `switch_user.parameter: HTTP_X_SWITCH_USER` in security.yaml. refs: symfony/symfony#39907
This PR was merged into the 4.4 branch. Discussion ---------- [Security] Update impersonating_user.rst To use switching user feature via `HTTP_X_SWITCH_USER` header we have to set `switch_user.parameter: HTTP_X_SWITCH_USER` in security.yaml. refs: symfony/symfony#39907 <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 38b42b8 Update impersonating_user.rst
Symfony version(s) affected: 5.2.0
Description
https://symfony.com/doc/current/security/impersonating_user.html
the documentation says
Instead of adding a _switch_user query string parameter, you can pass the username in a HTTP_X_SWITCH_USER header.
however it doesn't work, so I have to use query parameter _switch_userHow to reproduce
set up new symfony project and follow instruction from the documentation https://symfony.com/doc/current/security/impersonating_user.html using header solution instead of query parameter
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: