In my current spring-boot project, the header for my views have the following instruction:
<a sec:authorize="hasRole('admin')" th:href="@{/home}">...</a>
which is not working when I run the application and open the view in the browser (even when the user has the role). In the same view, I also use sec:authorize="isAuthenticated()"
and sec:authorize="isAnonymous()"
, both working fine. In my java code, I have some methods with this annotation:
@PreAuthorize("hasRole('admin')")
which working fine, too. Why this is not working in the view? Anyone can tell me what's wrong here?