Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 access_control, Match all routes containing some word

Tags:

symfony

The following only matches a path that starts with private:

access_control:
    #...
    - { path: ^/private, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
    - { path: ^/private, roles: ROLE_NO_ACCESS }

How can I match all the routes that contain /private/ (and do not necessarily start with private)? For example, something that will match /message/private/blabla.. the equivalent of [path~="private"] with jQuery selectors.

Note: Does anyone know how we call the regex we are using here? Is this specific to yml or is this implemented by Symfony, I am confused. Is there a chance I missed this in the doc somewhere, I mean the description with the specific matching patterns like start with, end with, contains etc....

like image 239
Mick Avatar asked Dec 28 '25 14:12

Mick


1 Answers

^/ this pattern says everything that starts (^) with slash (/) and so on.

I suppose that /private or something like */private should work

like image 111
DonCallisto Avatar answered Dec 31 '25 19:12

DonCallisto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!