Skip to content

Add documentation about impersonating users with an HTTP Header #14140

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

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion security/impersonating_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ as the value to the current URL:

http://example.com/somewhere?_switch_user=thomas

.. tip::

Instead of adding a ``_switch_user`` query string parameter, you can pass
the username in a ``HTTP_X_SWITCH_USER`` header.

To switch back to the original user, use the special ``_exit`` username:

.. code-block:: text
Expand Down Expand Up @@ -197,7 +202,7 @@ Limiting User Switching

If you need more control over user switching, you can use a security voter. First,
configure ``switch_user`` to check for some new, custom attribute. This can be
anything, but *cannot* start with ``ROLE_`` (to enforce that only your voter will
anything, but *cannot* start with ``ROLE_`` (to enforce that only your voter will
be called):

.. configuration-block::
Expand Down