Keycloak 不返回密码过期错误

Keycloak not returning password expired error

我正在使用 Keycloak 3.4 和 Active Directory(用于用户联合)来保护我的 Api,系统配置为使用 资源所有者密码凭证流程 .当用户密码过期时,我收到 无效的用户凭据 错误。

他们有什么方法可以 return 相应的错误消息消息,例如用户 用户密码已过期

回答我自己的问题,解决方案是扩展 MSADUserAccountControlsMapper 以抛出适当的异常,然后在 AbstractUsernameFormAuthenticator 的子类中捕获它。

参见:https://issues.jboss.org/browse/KEYCLOAK-2634