Skip to content

Commit 1996e67

Browse files
committed
clarify that user context url needs to be available to anonymous users
1 parent f12b74b commit 1996e67

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Resources/doc/features/user-context.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You need to configure a route for the context hash. It does not specify any
4949
controller, as the request listener will abort the request right after the
5050
firewall has been applied, but the route definition must exist. Use the same
5151
path as you specified in the caching proxy and make sure that this path is
52-
covered by your
52+
allowed for anonymous users and covered by your
5353
`firewall configuration <http://symfony.com/doc/current/book/security.html>`_:
5454

5555
.. code-block:: yaml
@@ -58,6 +58,17 @@ covered by your
5858
user_context_hash:
5959
path: /_fos_user_context_hash
6060
61+
If your access rules limit the whole site to logged in users, make sure to
62+
handle the user context URL like the login page:
63+
64+
.. code-block:: yaml
65+
66+
# app/config/security.yml
67+
access_control:
68+
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
69+
- { path: ^/_fos_user_context_hash, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
70+
- { path: ^/, roles: ROLE_USER }
71+
6172
Finally, enable the subscriber with the default settings:
6273

6374
.. code-block:: yaml

0 commit comments

Comments
 (0)