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

[Security] Reference the new request_matcher option#16296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletionssecurity.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2119,6 +2119,12 @@ would match ``/admin/foo`` but would also match URLs like ``/foo/admin``.

Each ``access_control`` can also match on IP address, hostname and HTTP methods.
It can also be used to redirect a user to the ``https`` version of a URL pattern.

.. versionadded:: 6.1

Since Symfony 6.1, an access control rule can also be directly configured by passing a service
implementing `RequestMatcherInterface` through the `request_matcher` option.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

backticks should be doubled

derrabus reacted with thumbs up emoji

See :doc:`/security/access_control`.

.. _security-securing-controller:
Expand Down
16 changes: 16 additions & 0 deletionssecurity/access_control.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,9 @@ Take the following ``access_control`` entries as an example:
- { path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' }
- { path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] }

# Request matchers can be used to define access control rules
- { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }

.. code-block:: xml

<!-- config/packages/security.xml -->
Expand DownExpand Up@@ -82,6 +85,9 @@ Take the following ``access_control`` entries as an example:
<ip>::1</ip>
<ip>%env(TRUSTED_IPS)%</ip>
</rule>

<!-- Request matchers can be used to define access control rules -->
<rule role="ROLE_USER" request-matcher="App\Security\RequestMatcher\MyRequestMatcher"/>
</config>
</srv:container>

Expand DownExpand Up@@ -127,8 +133,18 @@ Take the following ``access_control`` entries as an example:
->roles(['ROLE_USER_IP'])
->ips(['127.0.0.1', '::1', '%env(TRUSTED_IPS)%'])
;

// Request matchers can be used to define access control rules
$security->accessControl()
->roles(['ROLE_USER'])
->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
;
};

.. versionadded:: 6.1

Support for access control rule definition based on a RequestMatcher was introduced in Symfony 6.1.

For each incoming request, Symfony will decide which ``access_control``
to use based on the URI, the client's IP address, the incoming host name,
and the request method. Remember, the first rule that matches is used, and
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp