@@ -28,7 +28,12 @@ options are used for matching:
28
28
* ``ip `` or ``ips ``: netmasks are also supported (can be a comma-separated string)
29
29
* ``port ``: an integer
30
30
* ``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.
32
37
33
38
Take the following ``access_control `` entries as an example:
34
39
@@ -52,7 +57,7 @@ Take the following ``access_control`` entries as an example:
52
57
- { path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' }
53
58
- { path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] }
54
59
55
- # Request matchers can be used to define access control rules
60
+ # for custom matching needs, use a request matcher service
56
61
- { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
57
62
58
63
.. code-block :: xml
@@ -86,7 +91,7 @@ Take the following ``access_control`` entries as an example:
86
91
<ip >%env(TRUSTED_IPS)%</ip >
87
92
</rule >
88
93
89
- <!-- Request matchers can be used to define access control rules -->
94
+ <!-- for custom matching needs, use a request matcher service -->
90
95
<rule role =" ROLE_USER" request-matcher =" App\Security\RequestMatcher\MyRequestMatcher" />
91
96
</config >
92
97
</srv : container >
@@ -134,17 +139,13 @@ Take the following ``access_control`` entries as an example:
134
139
->ips(['127.0.0.1', '::1', env('TRUSTED_IPS')])
135
140
;
136
141
137
- // Request matchers can be used to define access control rules
142
+ // for custom matching needs, use a request matcher service
138
143
$security->accessControl()
139
144
->roles(['ROLE_USER'])
140
145
->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
141
146
;
142
147
};
143
148
144
- .. versionadded :: 6.1
145
-
146
- Support for access control rule definition based on a RequestMatcher was introduced in Symfony 6.1.
147
-
148
149
For each incoming request, Symfony will decide which ``access_control ``
149
150
to use based on the URI, the client's IP address, the incoming host name,
150
151
and the request method. Remember, the first rule that matches is used, and
0 commit comments