开发者

Spring Security 3: Is it possible to see which AuthenticationProvider has authenticated a session?

I have an AuthenticationManager with multiple AuthenticationProviders. That works very well, the first AP that can auth² the Authentication authenticates the user and if none can, the user is refused.

Now I have an a bit more special case, and I need to find out which AuthenticationProvider authenticated a user that was authenticated successfully. I cannot se开发者_开发技巧em to find a way in which this can be done in a stable and reliable fashion.

I can imagine some creative hacks (e.g. interleaving instances of an own AuthenticationProvider that always fails to authenticate, but which can help infer which was the last AuthenticationProvider that was seen), but that's really not the point. Is there an official way to do this?


I haven't tried it but you might be able to hook into the events that are fired on successful authentications and get the information you are looking for

AuthenticationSuccessEvent: Application event which indicates successful authentication. InteractiveAuthenticationSuccessEvent:Indicates an interactive authentication was successful.

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

InteractiveAuthenticationSuccessEvent, has a property which tells you the class which fired the event


Why not just store that information along with the UserDetails stuff in the current session?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜