Skip to content

Commit f24648b

Browse files
authored
Merge pull request #294 from FriendsOfSymfony/clarify-context-hash-permissions
clarify that user context url needs to be available to anonymous users
2 parents f12b74b + e1e69d9 commit f24648b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-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

Resources/doc/spelling_word_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ lookup
1414
lookups
1515
TTL
1616
multi
17+
login
1718
logout

0 commit comments

Comments
 (0)