Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression security pattern in symfony2

Tags:

regex

symfony

I'm working on WSSE Authentication for a REST API (in symfony2)

In the security.yml i have to put a regular expression in the pattern parameter for restricting url access.

pattern:   ^/api/.*[^(connect|docs/.*)]

This regex is not working, and i have tried a lot of other combinaisons..

I would to restrict access for all API calls like :

/api/anything **BUT EXCEPT** for /api/connect **OR**  /api/docs/ **OR** /api/docs/anything
like image 709
Benjamin B. Avatar asked Dec 06 '22 10:12

Benjamin B.


1 Answers

You can use negative lookahead:

^/api/(?!(connect|docs/)).*$
like image 140
David Pärsson Avatar answered Dec 09 '22 01:12

David Pärsson