Skip to content

Commit fc96d8a

Browse files
Allow specifying attributes for RequestMatcher for YAML format
1 parent 259530a commit fc96d8a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

security/access_control.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ options are used for matching:
3030
* ``host``: a regular expression
3131
* ``methods``: one or many HTTP methods
3232
* ``request_matcher``: a service implementing ``RequestMatcherInterface``
33+
* ``attributes``: is an array, which can be used to specify attributes of the query
34+
* ``route``: a route name
3335

3436
.. versionadded:: 6.1
3537

3638
The ``request_matcher`` option was introduced in Symfony 6.1.
3739

40+
.. versionadded:: 6.2
41+
42+
The ``route`` and ``attributes`` options were introduced in Symfony 6.2.
43+
3844
Take the following ``access_control`` entries as an example:
3945

4046
.. configuration-block::
@@ -60,6 +66,10 @@ Take the following ``access_control`` entries as an example:
6066
# for custom matching needs, use a request matcher service
6167
- { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
6268
69+
# require ROLE_ADMIN for 'admin' route. You can use the shortcut "route: xxx", instead of "attributes": ["_route": "xxx"].
70+
- { attributes: {'_route': 'admin'}, roles: ROLE_ADMIN }
71+
- { route: 'admin', roles: ROLE_ADMIN }
72+
6373
.. code-block:: xml
6474
6575
<!-- config/packages/security.xml -->

0 commit comments

Comments
 (0)