Reputation: 13222
I want to generate some html content based on the user rights of a user who logged in with spring-security. I can't find much about this subject on the internet so far and i'm wondering what would be a good way to implement this.
So far i was thinking about making a custom tag, attach it to a controller who links to a class that can generate, for example, the menu. I'm just not sure how get the user roles/rights of the user from spring-security.
Upvotes: 0
Views: 1727
Reputation: 38300
How about something like this:
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> ... <body> Shared content for all roles. <sec:authorize access="hasRole('roleName1')"> content for roleName1 </sec:authorize> <sec:authorize access="hasRole('roleName2')"> content for roleName2 </sec:authorize> More shared content for all roles. </body>
Upvotes: 1
Reputation: 17472
Check the spring security tags to create dynamic content based on user roles. Spring Security Taglibs reference.
Upvotes: 2