gpt4 book ai didi

java - Spring 安全 3 : Is it possible to see which AuthenticationProvider has authenticated a session?

转载 作者:行者123 更新时间:2023-11-30 09:53:47 25 4
gpt4 key购买 nike

我有一个带有多个 AuthenticationProvider 的 AuthenticationManager。这非常有效,第一个可以对身份验证进行身份验证的 AP 对用户进行身份验证,如果没有人可以,则拒绝该用户。

现在我有一个更特殊的情况,我需要找出哪个 AuthenticationProvider 对已成功通过身份验证的用户进行了身份验证。我似乎找不到以稳定可靠的方式完成此操作的方法。

我可以想象一些创造性的 hack(例如,交错始终无法通过身份验证的自己的 AuthenticationProvider 的实例,但这可以帮助推断哪个是最后一个看到的 AuthenticationProvider),但这真的不是重点。有官方的方法可以做到这一点吗?

最佳答案

我还没有尝试过,但您可能能够连接到成功验证时触发的事件并获取您正在寻找的信息

AuthenticationSuccessEvent:表示身份验证成功的应用程序事件。InteractiveAuthenticationSuccessEvent:表示交互认证成功。

http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/event/package-summary.html

InteractiveAuthenticationSuccessEvent,有一个 property它告诉你触发事件的类

关于java - Spring 安全 3 : Is it possible to see which AuthenticationProvider has authenticated a session?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3674006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com