我现在正在运行 Grails 3.1.15 和org.grails.plugins:spring-security-core:3.1.1
.
当我返回状态代码时,403
我ErrorController
应该生成一个适当的错误页面(映射到 中UrlMappings
)。它需要springSecurityService.currentUser
生成该错误页面。
事实证明,我进入NPE
了该过程,因为springSecurityService.currentUser
它是 null 以及身份验证对象。
这在 Grails2和v2
.spring-security-plugin
我遇到了这个问题:Spring SecurityContext 在错误页面上返回空身份验证,并且建议ExceptionTranslationFilter
必须到位。在 Grails2 中它确实存在,但在 Grails3 中它被替换/扩展为UpdateRequestContextHolderExceptionTranslationFilter
- 它仍然在过滤器链中。
当错误处理403
评论:
- 整个情况仅在部署在 Tomcat 中时发生在生产环境中 - 在开发模式下不可重现