thymeleaf-extras-springsecurity icon indicating copy to clipboard operation
thymeleaf-extras-springsecurity copied to clipboard

Make springsecurity extras available on error page?

Open fapdash opened this issue 7 years ago • 1 comments

I've noticed that the extras provided by this package don't seem to be available when rendering the Spring error pages after an Exception. (e.g. error.html) ${#authentication.name} fails with a NPE. Elements with sec:authentication="name" don't get rendered.

Is this a problem with my configuration or is this a limitation of thymeleaf-extras-springsecurity?

My thymeleaf dependencies (with Spring Boot 1.5.10):

compile group: 'org.thymeleaf', name: 'thymeleaf', version: '3.0.7.RELEASE'
compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.7.RELEASE'
compile 'org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.1.RELEASE'
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '2.2.2'
compile group: 'io.github.jpenren', name: 'thymeleaf-spring-data-dialect', version: '3.3.0'
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'

fapdash avatar Mar 19 '18 21:03 fapdash

This isn't Thymeleaf issue but rather the way how Spring Security is configured by default in Spring Boot (the filter doesn't bind to ERROR requests and that's why authentication info isn't available on error pages). This has been fixed in Spring Boot >= 2.0: https://github.com/spring-projects/spring-boot/issues/8289

But for 1.5, you need to add the following configuration:

security.filter-dispatcher-types: ASYNC, REQUEST, ERROR

php-coder avatar Apr 04 '20 15:04 php-coder