Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails REST安全性-密码已过期_Rest_Grails_Spring Security_Passwords - Fatal编程技术网

Grails REST安全性-密码已过期

Grails REST安全性-密码已过期,rest,grails,spring-security,passwords,Rest,Grails,Spring Security,Passwords,我有一个应用程序启动并运行,REST身份验证工作正常,但现在想添加密码过期(这将通过quartz作业在默认用户类上设置属性-boolean passwordExpired完成) 有人能告诉我正确的方向来处理过期的密码异常,返回类似403的内容,指示在前端输入新密码,而不是401 我在日志中看到以下内容: DEBUG userdetails.DefaultPostAuthenticationChecks - User account credentials have expired DE

我有一个应用程序启动并运行,REST身份验证工作正常,但现在想添加密码过期(这将通过quartz作业在默认用户类上设置属性-boolean passwordExpired完成)

有人能告诉我正确的方向来处理过期的密码异常,返回类似403的内容,指示在前端输入新密码,而不是401

我在日志中看到以下内容:

DEBUG userdetails.DefaultPostAuthenticationChecks  - User account credentials have     expired
DEBUG rest.RestAuthenticationFilter  - Authentication failed: User credentials have     expired
DEBUG bearer.BearerTokenAuthenticationFailureHandler  - Sending status code 401 and header WWW-Authenticate: Bearer
假设我必须在某个地方重写一个方法,但我对grails不熟悉,不知道如何做到这一点


谢谢你想出了一个解决办法

供其他人参考:- 1) 已禁用承载令牌支持(不确定是否需要,但其工作正常)

2) 创建一个实现

class CustomRestAuthenticationFailureHandler implements AuthenticationFailureHandler {@
    Override
    void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse     response, AuthenticationException exception) {
        def statuscode = HttpServletResponse.SC_FORBIDDEN
            ...
            // do something based on the exception message and change the status or add a     message to response.body
    }
3) 将bean添加到resources.groovy

beans = {

  restAuthenticationFailureHandler(CustomRestAuthenticationFailureHandler) {

  }
}
beans = {

  restAuthenticationFailureHandler(CustomRestAuthenticationFailureHandler) {

  }
}