Commit a6bbc81d authored by Fabien Potencier's avatar Fabien Potencier

minor #1570 Update security.rst - security context sharing (Flyrell)

This PR was squashed before being merged into the 2.2.x-dev branch (closes #1570).

Discussion
----------

Update security.rst - security context sharing

I'd like to update the security.rst as I found the lack of information about the security context sharing between multiple firewalls. I know a lot of people are having problems not knowing this, so it would be nice to mention it. Please, check the correctness and approve it if you find it useful. Thanks.

Commits
-------

2b81227d Update security.rst - security context sharing
parents f5f3d73b 2b81227d
...@@ -420,6 +420,35 @@ switch back to their primary account: ...@@ -420,6 +420,35 @@ switch back to their primary account:
You are an admin but you've switched to another user, You are an admin but you've switched to another user,
<a href="?_switch_user=_exit"> exit</a> the switch. <a href="?_switch_user=_exit"> exit</a> the switch.
{% endif %} {% endif %}
Sharing security context between multiple firewalls
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, all the firewalls have a different **security context**.
In case you need to share the same security context between multiple firewalls
you can set the ``context`` setting for each firewall you want the context to be shared with.
$app['security.firewalls'] = array(
'login' => array(
'context' => 'admin_security',
'pattern' => '^/login',
// ...
),
'secured' => array(
'context' => 'admin_security',
'pattern' => '^/admin/',
'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'),
'users' => array(
'admin' => array('ROLE_ADMIN', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'),
),
// ...
),
);
Above configuration ensures that you have the same security context ``admin_security``
inside both , ``login`` and ``admin`` firewalls. This might be useful for instance
to redirect already logged in users to the secured area of your website when they visit the login form,
as you have the possibility to check if the user has been granted the ``ROLE_ADMIN`` role inside the ``login`` firewall.
Defining a Role Hierarchy Defining a Role Hierarchy
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment