I struggle to get Thymeleaf to work with Spring Security in my Spring Boot 1.4.3 based project.
Tags like e.g.
If you use Spring Boot 2.0.0.RELEASE:
org.springframework.boot
spring-boot-starter-parent
2.0.0.RELEASE
you need just the following dependencies:
org.springframework.boot
spring-boot-starter-security
org.thymeleaf.extras
thymeleaf-extras-springsecurity4
Version of thymeleaf-extras-springsecurity4
will be inherited from the spring-boot-starter-parent
and would be 3.0.2.RELEASE.
Thanks to @yglodt for pointing this out.
Also in your templates add spring-security namespace xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
and use hasRole
instead of hasAuthority
value in
tag:
...