@@ -715,6 +715,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
715
715
# require ROLE_ADMIN for /admin*
716
716
- { path: ^/admin, roles: ROLE_ADMIN }
717
717
718
+ # the 'path' value can be any valid regular expression
719
+ # (this one will match URLs like /api/post/7298 and /api/comment/528491)
720
+ - { path: ^/api/(post|comment)/\d+$, roles: ROLE_USER }
721
+
718
722
.. code-block :: xml
719
723
720
724
<!-- app/config/security.xml -->
@@ -734,6 +738,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
734
738
735
739
<!-- require ROLE_ADMIN for /admin* -->
736
740
<rule path =" ^/admin" role =" ROLE_ADMIN" />
741
+
742
+ <!-- the 'path' value can be any valid regular expression
743
+ (this one will match URLs like /api/post/7298 and /api/comment/528491) -->
744
+ <rule path =" ^/api/(post|comment)/\d+$" role =" ROLE_USER" />
737
745
</config >
738
746
</srv : container >
739
747
@@ -752,6 +760,10 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
752
760
'access_control' => [
753
761
// require ROLE_ADMIN for /admin*
754
762
['path' => '^/admin', 'role' => 'ROLE_ADMIN'],
763
+
764
+ // the 'path' value can be any valid regular expression
765
+ // (this one will match URLs like /api/post/7298 and /api/comment/528491)
766
+ ['path' => '^/api/(post|comment)/\d+$', 'role' => 'ROLE_USER'],
755
767
],
756
768
]);
757
769
0 commit comments