Skip to content

Be more explicit about the use of regular expressions in access_control #12279

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Changes from all 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
12 changes: 12 additions & 0 deletions security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }

# the 'path' value can be any valid regular expression
# (this one will match URLs like /api/post/7298 and /api/comment/528491)
- { path: ^/api/(post|comment)/\d+$, roles: ROLE_USER }

.. code-block:: xml

<!-- app/config/security.xml -->
Expand All @@ -734,6 +738,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio

<!-- require ROLE_ADMIN for /admin* -->
<rule path="^/admin" role="ROLE_ADMIN"/>

<!-- the 'path' value can be any valid regular expression
(this one will match URLs like /api/post/7298 and /api/comment/528491) -->
<rule path="^/api/(post|comment)/\d+$" role="ROLE_USER"/>
</config>
</srv:container>

Expand All @@ -752,6 +760,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
'access_control' => [
// require ROLE_ADMIN for /admin*
['path' => '^/admin', 'role' => 'ROLE_ADMIN'],

// the 'path' value can be any valid regular expression
// (this one will match URLs like /api/post/7298 and /api/comment/528491)
['path' => '^/api/(post|comment)/\d+$', 'role' => 'ROLE_USER'],
],
]);

Expand Down