I'm using keycloak for authentication and authorization with Spring Boot and Thymeleaf.
I'm trying to secure some areas, for example if the user has the role ROLE_TEC, I have to hide some part of the view, so I'm doing the following:
<li class="nav-item dropdown" sec:authorize="hasRole('ROLE_TEC')">
//some html
</li>
The user that I'm using has that role, but I can't see that piece of page. Why?
Do I have to add any configuration about thymeleaf for keycloak or Spring security?
EDIT
If I use:
<span sec:authentication="authorities"></span>
I obtain this:
[KeycloakRole{role='TEC'}, KeycloakRole{role='USER'}]
I think this is the solution:
<li class="nav-item dropdown" sec:authorize="hasAuthority('TEC')">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With