user471011
user471011

Reputation: 7374

Spring Security. Different view for the same page for different roles, possible?

For example, we have Book List page.

This Page contains list of books.

If user role = "ADMIN" show on Page button "Remove Book" or something like "Edit Book".

If user role = "SIMPLY_USER" user can not see any buttons likes "Remove.." or "Edit...".

After quick look on Spring Security 3 - I cant find any implementation for my case.

It is true?

Upvotes: 3

Views: 2311

Answers (1)

Arnaud Gourlay
Arnaud Gourlay

Reputation: 4666

You can use the spring security taglib in your jsp to decide what to display according to the user role.

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authorize access="hasRole('supervisor')">

This content will only be visible to users who have
the "supervisor" authority in their list of <tt>GrantedAuthority</tt>s.

</sec:authorize>

Reference : http://static.springsource.org/spring-security/site/docs/3.0.x/reference/taglibs.html

Upvotes: 12

Related Questions