UndefinedBehavior
UndefinedBehavior

Reputation: 908

Spring security regex patern matcher and '/' character

In my spring security configuration I have

<http auto-config="true" use-expressions="true" path-type="regex">
...
<intercept-url pattern="/admin/*" access="hasRole('ROLE_ADMIN')" />

This pattern matches the path "/admin" as well, even if this string is not produced by the regex "/admin/*" (there is no slash at the end). Why is that? I found no documentation about it. Does regex path matching have any other peculiarity like this one? I am using Spring Security 3.0.

EDIT I obviously was mistaking "" for ".". Should have taken a nap instead of asking it here :)

Upvotes: 0

Views: 2827

Answers (1)

Eric
Eric

Reputation: 1374

* in a regex means "match the preceding character zero or more times", so your regex does match the string "/admin".

You probably want to use + which means "match the preceding character one or more times".

Upvotes: 2

Related Questions