我有一个客户端/服务器应用程序,使用 Spring,更具体地说,使用 Spring Security 来管理客户端的身份验证。 一切正常,这是配置的相关部分:
<security:authentication-manager id="authenticationManager">
<security:authentication-provider>
<security:password-encoder hash="md5" />
<security:jdbc-user-service data-source-ref="dataSource" users-by-username-query="
select username,password,attivo
from Operatore where username=?"
authorities-by-username-query="
select username,ruolo
from Operatore where username=? " />
</security:authentication-provider>
</security:authentication-manager>
我的问题是否有一种方法可以授权使用 passepartout 密码的用户。 我的意思是,有时特定用户可以使用 super 管理员密码轻松登录软件,以便在不更改密码的情况下准确查看用户所看到的内容。
我认为 Spring 没有考虑到这种行为;有办法实现这种行为吗?
最佳答案
您可以编写自己的身份验证逻辑,只需连接您自己的 AuthenticationProvider 实现并根据需要实现身份验证方法即可:
进一步阅读:
http://www.baeldung.com/spring-security-authentication-provider
https://danielkaes.wordpress.com/2013/02/20/custom-authentication-provider-in-spring/
关于java - Spring Security 路路通密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33675029/