Benjamin B.
Benjamin B.

Reputation: 483

Regular Expression security pattern in symfony2

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

Upvotes: 4

Views: 8176

Answers (1)

David Pärsson
David Pärsson

Reputation: 6257

You can use negative lookahead:

^/api/(?!(connect|docs/)).*$

Upvotes: 15

Related Questions