kyrpav
kyrpav

Reputation: 778

sec:authorize does not work on thymeleaf with hasRole(ROLE_ADMIN) or other

I am trying to authorize access to some buttons to some specific lvl of authority. I have seen other questions, but all solutions that i saw did not work.

i have doing:

        <div class="col-sm-2" sec:authorize="hasRole('ROLE_ADMIN')">
            <a href="#"><button type="button" class="btn btn-danger"> <b>Approve Plan </b></button></a> 
        </div>

i have also tested.

sec:authorize="hasRole('ADMIN')"
sec:authorize="hasRole('APPROVER')"
sec:authorize="hasAuthority('ADMIN')"

The button is always shown independent of the user authority thought it should be visible only to approver.

Upvotes: 0

Views: 441

Answers (1)

Alien
Alien

Reputation: 15878

Make sure you have below dependency in pom.xml.

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity4</artifactId>
    <version>3.0.2.RELEASE</version>
</dependency>

Refer this

Upvotes: 1

Related Questions