Reputation: 8855
i am using spring security 3.1.4. for some reason, access to resources is not being filtered correctly. my security xml file looks like the following.
<http auto-config="true">
<intercept-url pattern="/**" access="ROLE_USER"/>
<intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
...
</http>
as you can see, what i want to express with this configuration is that a USER can access any resource unless they are accessing resources mapped to /admin/something.
when i log in as a user with ROLE_USER only (verified in the database, as i am using the jdbc-user-service), i can still point my browser to
/myapp/admin/default
and see all the contents.
i then change my security xml to look like the following.
<http auto-config="true">
<intercept-url pattern="/**" access="ROLE_ADMIN"/>
<intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
...
</http>
when i log in as a user with ROLE_USER, then i get a HTTP 403 Access is denied.
my questions are
any help is appreciated.
Upvotes: 0
Views: 779
Reputation: 1096
Try putting the admin pattern before the more general /** pattern. From the docs (http://docs.spring.io/spring-security/site/docs/3.0.x/reference/core-web-filters.html) the most specific patterns need to be declared higher in the list of patterns.
<http auto-config="true">
<intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
<intercept-url pattern="/**" access="ROLE_USER"/>
...
</http>
Upvotes: 3