Use JSF + Spring Security.
Solution 1 - User Interface Oriented:
JSF page displays a panel with users if the registered person has only ROLE_ADMIN .
<p:panel rendered="#{facesContext.externalContext.isUserInRole('ROLE_ADMIN')}"> ...
Solution 2 - backend-oriented (annotate the corresponding DAO method):
@Transactional @PreAuthorize("hasRole('ROLE_ADMIN')") public List<User> getUsers() { return sessionFactory.getCurrentSession().createCriteria(User.class) .list(); }
Summary:
It seems that the JSF rendered attribute is not a flexible solution, and the annotated DAO methods are not user friendly due to redirection to 403 .
What is an elegant solution that allows me NOT to display a panel or link that does not correspond to specific permissions?
source share