简体   繁体   English

使用Grails Spring Security Rest插件时如何获取客户端登录失败的原因?

[英]How to get the reason of login failure in clients while using Grails Spring Security Rest plugin?

We are using Grails Spring Security Rest plugin 1.5.2 with Grails 2.5.2. 我们正在使用Grails Spring Security Rest插件1.5.2和Grails 2.5.2。

Unfortunately it doesn't seem to report any reason of why a login failure occurred. 不幸的是,它似乎没有报告任何导致登录失败的原因。 The only thing we get from the login request is HTTP 401 . 从登录请求中获得的唯一内容是HTTP 401

We have a mechanism where after a number of login failures we set the accountLocked property of the User , so the account becomes disabled/locked. 我们有一种机制,在多次登录失败后,我们设置UseraccountLocked属性,因此该帐户将被禁用/锁定。

We would like to get at least a JSON response of why the login failed, like "User account is locked", "Bad credentials", "No such user", etc. 我们希望至少获得有关登录失败原因的JSON响应,例如“用户帐户已锁定”,“错误的凭据”,“没有此类用户”等。

Is there a way to do this with current versions that we use? 有没有办法对我们使用的当前版本执行此操作?

The plugin doesn't support that out of the box. 该插件不支持该功能。 However, you can easily workaround it by replacing RestAuthenticationFailureHandler with your own implementation and wiring it in resources.groovy as restAuthenticationFailureHandler . 但是,您可以通过用您自己的实现替换RestAuthenticationFailureHandler并将其连接到resources.groovy作为restAuthenticationFailureHandler来轻松解决此restAuthenticationFailureHandler

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM