@@ -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
3338Take the following ``access_control `` entries as an example:
3439
@@ -52,6 +57,9 @@ 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
60+ # for custom matching needs, use a request matcher service
61+ - { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
62+
5563 .. code-block :: xml
5664
5765 <!-- config/packages/security.xml -->
@@ -82,6 +90,9 @@ Take the following ``access_control`` entries as an example:
8290 <ip >::1</ip >
8391 <ip >%env(TRUSTED_IPS)%</ip >
8492 </rule >
93+
94+ <!-- for custom matching needs, use a request matcher service -->
95+ <rule role =" ROLE_USER" request-matcher =" App\Security\RequestMatcher\MyRequestMatcher" />
8596 </config >
8697 </srv : container >
8798
@@ -127,6 +138,12 @@ Take the following ``access_control`` entries as an example:
127138 ->roles(['ROLE_USER_IP'])
128139 ->ips(['127.0.0.1', '::1', env('TRUSTED_IPS')])
129140 ;
141+
142+ // for custom matching needs, use a request matcher service
143+ $security->accessControl()
144+ ->roles(['ROLE_USER'])
145+ ->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
146+ ;
130147 };
131148
132149 For each incoming request, Symfony will decide which ``access_control ``
0 commit comments