Skip to content

Commit f46f149

Browse files
committed
Tweaks
1 parent 11b0377 commit f46f149

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

security.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,11 +2117,7 @@ would match ``/admin/foo`` but would also match URLs like ``/foo/admin``.
21172117

21182118
Each ``access_control`` can also match on IP address, hostname and HTTP methods.
21192119
It can also be used to redirect a user to the ``https`` version of a URL pattern.
2120-
2121-
.. versionadded:: 6.1
2122-
2123-
Since Symfony 6.1, an access control rule can also be directly configured by passing a service
2124-
implementing `RequestMatcherInterface` through the `request_matcher` option.
2120+
For more complex needs, you can also use a service implementing ``RequestMatcherInterface``.
21252121

21262122
See :doc:`/security/access_control`.
21272123

security/access_control.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ options are used for matching:
2828
* ``ip`` or ``ips``: netmasks are also supported (can be a comma-separated string)
2929
* ``port``: an integer
3030
* ``host``: a regular expression
31-
* ``methods``: one or many methods
31+
* ``methods``: one or many HTTP methods
32+
* ``request_matcher``: a service implementing ``RequestMatcherInterface``
33+
34+
.. versionadded:: 6.1
35+
36+
The ``request_matcher`` option was introduced in Symfony 6.1.
3237

3338
Take the following ``access_control`` entries as an example:
3439

@@ -52,7 +57,7 @@ Take the following ``access_control`` entries as an example:
5257
- { path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' }
5358
- { path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] }
5459
55-
# Request matchers can be used to define access control rules
60+
# for custom matching needs, use a request matcher service
5661
- { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
5762
5863
.. code-block:: xml
@@ -86,7 +91,7 @@ Take the following ``access_control`` entries as an example:
8691
<ip>%env(TRUSTED_IPS)%</ip>
8792
</rule>
8893
89-
<!-- Request matchers can be used to define access control rules -->
94+
<!-- for custom matching needs, use a request matcher service -->
9095
<rule role="ROLE_USER" request-matcher="App\Security\RequestMatcher\MyRequestMatcher"/>
9196
</config>
9297
</srv:container>
@@ -134,17 +139,13 @@ Take the following ``access_control`` entries as an example:
134139
->ips(['127.0.0.1', '::1', env('TRUSTED_IPS')])
135140
;
136141
137-
// Request matchers can be used to define access control rules
142+
// for custom matching needs, use a request matcher service
138143
$security->accessControl()
139144
->roles(['ROLE_USER'])
140145
->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
141146
;
142147
};
143148
144-
.. versionadded:: 6.1
145-
146-
Support for access control rule definition based on a RequestMatcher was introduced in Symfony 6.1.
147-
148149
For each incoming request, Symfony will decide which ``access_control``
149150
to use based on the URI, the client's IP address, the incoming host name,
150151
and the request method. Remember, the first rule that matches is used, and

0 commit comments

Comments
 (0)