Skip to content

[Security] description for special role ROLE_PREVIOUS_ADMIN #1966

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
Nov 26, 2012
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
18 changes: 18 additions & 0 deletions book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,24 @@ To switch back to the original user, use the special ``_exit`` username:

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

During impersonation the user is provided with a special role called
``ROLE_PREVIOUS_ADMIN``. In a template, for instance, this role can decide
if a link to exit impersonation needs to be shown:

.. configuration-block::

.. code-block:: html+jinja

{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<a href="{{ path('homepage', {_switch_user: '_exit'}) }}">Exit impersonation</a>
{% endif %}

.. code-block:: html+php

<?php if ($view['security']->isGranted('ROLE_PREVIOUS_ADMIN')): ?>
<a href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>">Exit impersonation</a>
<?php endif; ?>

Of course, this feature needs to be made available to a small group of users.
By default, access is restricted to users having the ``ROLE_ALLOWED_TO_SWITCH``
role. The name of this role can be modified via the ``role`` setting. For
Expand Down