8000 Merge branch '3.4' into 4.3 · symfony/symfony-docs@53000c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53000c7

Browse files
committed
Merge branch '3.4' into 4.3
* 3.4: Be more explicit about the use of regular expressions in access_control
2 parents 7cb2585 + 6e787e9 commit 53000c7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

security.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ start with ``/admin``, you can:
437437
# require ROLE_ADMIN for /admin*
438438
- { path: ^/admin, roles: ROLE_ADMIN }
439439
440+
# the 'path' value can be any valid regular expression
441+
# (this one will match URLs like /api/post/7298 and /api/comment/528491)
442+
- { path: ^/api/(post|comment)/\d+$, roles: ROLE_USER }
443+
440444
.. code-block:: xml
441445
442446
<!-- config/packages/security.xml -->
@@ -456,6 +460,10 @@ start with ``/admin``, you can:
456460
457461
<!-- require ROLE_ADMIN for /admin* -->
458462
<rule path="^/admin" role="ROLE_ADMIN"/>
463+
464+
<!-- the 'path' value can be any valid regular expression
465+
(this one will match URLs like /api/post/7298 and /api/comment/528491) -->
466+
<rule path="^/api/(post|comment)/\d+$" role="ROLE_USER"/>
459467
</config>
460468
</srv:container>
461469
@@ -474,6 +482,10 @@ start with ``/admin``, you can:
474482
'access_co 6969 ntrol' => [
475483
// require ROLE_ADMIN for /admin*
476484
['path' => '^/admin', 'role' => 'ROLE_ADMIN'],
485+
486+
// the 'path' value can be any valid regular expression
487+
// (this one will match URLs like /api/post/7298 and /api/comment/528491)
488+
['path' => '^/api/(post|comment)/\d+$', 'role' => 'ROLE_USER'],
477489
],
478490
]);
479491

0 commit comments

Comments
 (0)
0