Reputation: 3
I am using Spring Security for providing access to users of my application. For single role I am using like this:
<security:intercept-url pattern="/rest/Admin" access="hasAuthority('Admin')" />
I want to provide access to user for a particular URL if he has both role of Admin
and Employee
but I am not sure how to do this.
Upvotes: 0
Views: 292
Reputation: 6444
According to Spring Security Reference:
To use expressions to secure individual URLs, you would first need to set the
use-expressions
attribute in the<http>
element totrue
. Spring Security will then expect theaccess
attributes of the<intercept-url>
elements to contain Spring EL expressions. The expressions should evaluate to a Boolean, defining whether access should be allowed or not. For example:<http> <intercept-url pattern="/admin*" access="hasRole('admin') and hasIpAddress('192.168.1.0/24')"/> ... </http>
So, you should try using:
<security:intercept-url pattern="/rest/Admin"
access="hasAuthority('Admin') and hasAuthority('Employee')" />
Upvotes: 2