@@ -52,6 +52,9 @@ Take the following ``access_control`` entries as an example:
52
52
- { path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' }
53
53
- { path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] }
54
54
55
+ # Request matchers can be used to define access control rules
56
+ - { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
57
+
55
58
.. code-block :: xml
56
59
57
60
<!-- config/packages/security.xml -->
@@ -82,6 +85,9 @@ Take the following ``access_control`` entries as an example:
82
85
<ip >::1</ip >
83
86
<ip >%env(TRUSTED_IPS)%</ip >
84
87
</rule >
88
+
89
+ <!-- Request matchers can be used to define access control rules -->
90
+ <rule role =" ROLE_USER" request-matcher =" App\Security\RequestMatcher\MyRequestMatcher" />
85
91
</config >
86
92
</srv : container >
87
93
@@ -127,8 +133,18 @@ Take the following ``access_control`` entries as an example:
127
133
->roles(['ROLE_USER_IP'])
128
134
->ips(['127.0.0.1', '::1', env('TRUSTED_IPS')])
129
135
;
136
+
137
+ // Request matchers can be used to define access control rules
138
+ $security->accessControl()
139
+ ->roles(['ROLE_USER'])
140
+ ->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
141
+ ;
130
142
};
131
143
144
+ .. versionadded :: 6.1
145
+
146
+ Support for access control rule definition based on a RequestMatcher was introduced in Symfony 6.1.
147
+
132
148
For each incoming request, Symfony will decide which ``access_control ``
133
149
to use based on the URI, the client's IP address, the incoming host name,
134
150
and the request method. Remember, the first rule that matches is used, and
0 commit comments