Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 342c66e

Browse filesBrowse files
committed
[symfony#2172] Adding more information about the firewall "context" key
1 parent 712ca65 commit 342c66e
Copy full SHA for 342c66e

File tree

Expand file treeCollapse file tree

2 files changed

+68
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+68
-3
lines changed

‎book/security.rst

Copy file name to clipboardExpand all lines: book/security.rst
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ Symfony's security system works by determining who a user is (i.e. authenticatio
148148
and then checking to see if that user should have access to a specific resource
149149
or URL.
150150

151+
.. _book-security-firewalls:
152+
151153
Firewalls (Authentication)
152154
~~~~~~~~~~~~~~~~~~~~~~~~~~
153155

@@ -656,8 +658,9 @@ see :doc:`/cookbook/security/form_login`.
656658
If you're using multiple firewalls and you authenticate against one firewall,
657659
you will *not* be authenticated against any other firewalls automatically.
658660
Different firewalls are like different security systems. To do this you have
659-
to explicitly specify the same context for different firewalls. But usually
660-
for most applications, having one main firewall is enough.
661+
to explicitly specify the same :ref:`reference-security-firewall-context`
662+
for different firewalls. But usually for most applications, having one
663+
main firewall is enough.
661664

662665
Authorization
663666
-------------

‎reference/configuration/security.rst

Copy file name to clipboardExpand all lines: reference/configuration/security.rst
+63-1Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ Each part will be explained in the next section.
7777
access_denied_handler: some.service.id
7878
entry_point: some.service.id
7979
provider: name
80-
context: name
80+
# manages where each firewall stores session information
81+
# See "Firewall Context" below for more details
82+
context: context_key
8183
stateless: false
8284
x509:
8385
provider: name
@@ -213,6 +215,66 @@ Redirecting after Login
213215
* ``target_path_parameter`` (type: ``string``, default: ``_target_path``)
214216
* ``use_referer`` (type: ``Boolean``, default: ``false``)
215217

218+
.. _reference-security-firewall-context:
219+
220+
Firewall Context
221+
----------------
222+
223+
Most applications will only need one :ref:`firewall<book-security-firewalls>`.
224+
But if your application *does* use multiple firewalls, you'll notice that
225+
if you're authenticated in one firewall, you're not automatically authenticated
226+
in another. In other words, the systems don't share a common "context": each
227+
firewall acts like a separate security system.
228+
229+
However, each firewall has an optional ``context`` key (which defaults to
230+
the name of the firewall), which is used when storing and retrieving security
231+
data to and from the session. If this key were set to the same value across
232+
multiple firewalls, the "context" could actually be shared:
233+
234+
.. configuration-block::
235+
236+
.. code-block:: yaml
237+
238+
# app/config/security.yml
239+
security:
240+
# ...
241+
242+
firewalls:
243+
somename:
244+
# ...
245+
context: my_context
246+
othername:
247+
# ...
248+
context: my_context
249+
250+
.. code-block:: xml
251+
252+
<!-- app/config/security.xml -->
253+
<security:config>
254+
<firewall name="somename" context="my_context">
255+
<! ... ->
256+
</firewall>
257+
<firewall name="othername" context="my_context">
258+
<! ... ->
259+
</firewall>
260+
</security:config>
261+
262+
.. code-block:: php
263+
264+
// app/config/security.php
265+
$container->loadFromExtension('security', array(
266+
'firewalls' => array(
267+
'somename' => array(
268+
// ...
269+
'context' => 'my_context'
270+
),
271+
'othername' => array(
272+
// ...
273+
'context' => 'my_context'
274+
),
275+
),
276+
));
277+
216278
HTTP-Digest Authentication
217279
--------------------------
218280

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.