paweloque
paweloque

Reputation: 18864

spring security filter-chain regex pattern

In my application which uses spring security I want to define two different areas both using their own spring security filter-chain. My question is: is it possible to define two regex expressions as follows:

  1. every path starting with /foobar/*
  2. every other path not starting with /foobar

The important part here is that the second path should also match if somewhere within it, but not in the beginning, it cotains the /foobar/ string.

Thanks

Upvotes: 4

Views: 2503

Answers (1)

Tim Pietzcker
Tim Pietzcker

Reputation: 336078

^/foobar/.*$

will match if the path starts with /foobar/;

^(?!/foobar/).*$

will match any path that doesn't start with /foobar/ ((?!...) is a so-called negative lookahead assertion).

Upvotes: 5

Related Questions