thegrid
thegrid

Reputation: 514

Spring Security Regex Exclude by path

I am using the following to allow access in Sprint Security to all URLs which match 'create.action'

<intercept-url pattern="^(.*?)(\bcreate.action\b)(.*)$" access="hasAnyRole('1','2')"/>

However i would like to grant access to /path1/path2/create.action to roles '3' and '4' i.e /path1/path2/create.action is an exception to the above rule.

I tried ^(.*?)(\b/path1/path2/create.action\b)(.*)$ but it doesn't work. I also tried the absolute path and that doesn't work too. Please help.

Upvotes: 0

Views: 497

Answers (1)

YouneL
YouneL

Reputation: 8369

You have to escape slashes \ and dots . and remove \b, it matches a word boundary where a word character is [a-zA-Z0-9_]

^(.*?)(\/path1\/path2\/create\.action)(.*)$

Upvotes: 1

Related Questions