kus*_*wal 8 java spring http spring-security spring-boot
我用来AuthenticationEntryPoint处理身份验证问题。将异常原因传递给最终用户。
response.sendError(responseCode, "errorReason")
Run Code Online (Sandbox Code Playgroud)
我最近将 Spring Boot 从“2.2.11.RELEASE”升级到“2.4.4”。从那时起它就不再工作了。它现在没有在客户端收到的响应中提供“errorReason”。spring-boot 最近引入了我所缺少的任何更改吗?
And*_*son 10
从 Spring Boot 2.3 开始,默认情况下该消息不再包含在错误响应中:
默认情况下,错误消息和任何绑定错误不再包含在默认错误页面中。这降低了向客户泄露信息的风险。
server.error.include-message并可server.error.include-binding-errors分别用于控制消息的包含和绑定错误。支持的值为always、on-param和never。
设置server.error.include-message=always将恢复 Spring Boot 2.2 的行为。
Spring boot 2.4.4 使用 Spring Security 5.4.5。AuthenticationException此版本中不再有 getMessage 方法(链接)。AuthenticationException然而,它仍然是您在应用程序中抛出的相同实例。所以你可以使用类似...
if (authException instanceof CustomAuthenticationException) {
CustomAuthenticationException ex = (CustomAuthenticationException) authException;
// handle your exception
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5310 次 |
| 最近记录: |