How to get the reason of login failure in clients

2019-08-09 02:30发布

We are using Grails Spring Security Rest plugin 1.5.2 with 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.

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.

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.

Is there a way to do this with current versions that we use?

1条回答
一夜七次
2楼-- · 2019-08-09 03:16

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.

查看更多
登录 后发表回答