thymeleaf / thymeleaf-extras-springsecurity

Thymeleaf "extras" integration module for Spring Security 3.x and 4.x
http://www.thymeleaf.org
Apache License 2.0
476 stars 107 forks source link

sec:authorize="isAnonymous()" no longer works with thymeleaf-extras-springsecurity5 #70

Open maykon-oliveira opened 4 years ago

maykon-oliveira commented 4 years ago

I have a Spring Boot 2.3.1 application that uses thymeleaf-extras-springsecurity5. The sec:authorize="isAnonymous()" it's not workning when user is no logged in. The sec:authorize="isAuthenticated()" works fine, after I login, the button logout appears.

pom.xml

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
            <version>3.0.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>

statement

<a sec:authorize="isAnonymous()" href="#" th:href="@{/login}"
     class="whitespace-no-wrap text-base leading-6 font-medium text-gray-500 hover:text-gray-900 focus:outline-none focus:text-gray-900">
       isAnonymous
</a>

Github repo: https://github.com/maykon-oliveira/exame-chunin-devdojo

ultraq commented 4 years ago

I don't know very much about WebFlux and Reactive stuff, but it looks like there might be a problem w/ the combination of Thymeleaf + Spring Security + WebFlux as this has also been reported in #68

roshanbachhav commented 9 months ago

sec:authorize="isAnonymous()" when not working then check following dependency

             <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>