Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0432c4

Browse files
TristanPouliquenjaviereguiluz
authored andcommitted
[Security] Reference the new request_matcher option
1 parentfc66fa3 commitf0432c4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎security.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,12 @@ would match ``/admin/foo`` but would also match URLs like ``/foo/admin``.
21192119

21202120
Each ``access_control`` can also match on IP address, hostname and HTTP methods.
21212121
It can also be used to redirect a user to the ``https`` version of a URL pattern.
2122+
2123+
..versionadded::6.1
2124+
2125+
Since Symfony 6.1, an access control rule can also be directly configured by passing a service
2126+
implementing `RequestMatcherInterface` through the `request_matcher` option.
2127+
21222128
See:doc:`/security/access_control`.
21232129

21242130
.. _security-securing-controller:

‎security/access_control.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Take the following ``access_control`` entries as an example:
5252
-{ path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' }
5353
-{ path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] }
5454
55+
# Request matchers can be used to define access control rules
56+
-{ roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
57+
5558
..code-block::xml
5659
5760
<!-- config/packages/security.xml-->
@@ -82,6 +85,9 @@ Take the following ``access_control`` entries as an example:
8285
<ip>::1</ip>
8386
<ip>%env(TRUSTED_IPS)%</ip>
8487
</rule>
88+
89+
<!-- Request matchers can be used to define access control rules-->
90+
<rulerole="ROLE_USER"request-matcher="App\Security\RequestMatcher\MyRequestMatcher"/>
8591
</config>
8692
</srv:container>
8793
@@ -127,8 +133,18 @@ Take the following ``access_control`` entries as an example:
127133
->roles(['ROLE_USER_IP'])
128134
->ips(['127.0.0.1', '::1', '%env(TRUSTED_IPS)%'])
129135
;
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+
;
130142
};
131143
144+
..versionadded::6.1
145+
146+
Support for access control rule definition based on a RequestMatcher was introduced in Symfony 6.1.
147+
132148
For each incoming request, Symfony will decide which ``access_control``
133149
to use based on the URI, the client's IP address, the incoming host name,
134150
and the request method. Remember, the first rule that matches is used, and

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp