grails/grails-spring-security-core

setting adh.errorPage to null causes Tomcat to fail on startup

jknudsen opened this issue · 2 comments

Setting the adh.errorPage to null causes an Application run failed message with an Exception provided below. Per the documentation null is valid and is what I have used with past versions of this plugin prior to the version 4 for Grails 4.

Steps to Reproduce

  1. Create Application and add the Spring Secuirty Plugin to build.gradle
  2. Set the adh.errorPage to null in application.yml

grails:
plugin:
springsecurity:
adh:
errorPage: null

Expected Behavior

Documentation says it should send a 403:

Location of the 403 error page (or set to null to send a 403 error and not render a page)

Actual Behaviour

Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'errorPage' threw exception; nested exception is java.lang.AssertionError: ErrorPage must begin with '/'. Expression: ((page == null) || page.startsWith(/)). Values: page =
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:135)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:79)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1705)
... 77 common frames omitted

Environment Information

  • Operating System: Windows 10
  • GORM Version: 7.0.8.RELEASE
  • Grails Version (if using Grails): 4.0.10
  • JDK Version: 8u152 tried 11 also
  • SpringSecurityPlug: org.grails.plugins:spring-security-core:4.0.3

Example Application

https://github.com/jknudsen/testspp

@jknudsen I don't think it is possible to map a null with yaml and spring boot](spring-projects/spring-framework#19986).

However, you can use application.groovy application.yml or both in Grails 4 or 5 applications.

Thus, you can use application.yml for everything and have an extra file at grails-app/conf/application.groovy

with the content:

grails.plugin.springsecurity.adh.errorPage = null

I have created a repo with a three and a five Grails applications:

https://github.com/grails-core-issues-forks/-grails-spring-security-core-issue-635-

Both behave the same.