我必须实现一个 spring 安全部分,它有超过 1 个参数来获取用户。它将通过 ID 和产品名称获取用户。我知道逐个用户名查询只能提供一个参数,我想知道是否可以提供许多逐个用户名查询选项并给他们某种 ID,但我不确定如何验证时将被引用。有没有人有什么建议
<sec:authentication-provider>
<sec:jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select username,password,enabled
from MY_USERS where username=? and product='productA'" />
您需要实施自己的认证提供者 http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/index.html?org/springframework/security/authentication/AuthenticationProvider.html
您不能重复使用Dao认证提供者 http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/dao/DaoAuthenticationProvider.html(jdbc-user-service),因为它使用用户详情服务 http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/core/userdetails/UserDetailsService.html,并且它有一种仅基于一个字符串参数加载 UserDetails 的方法UserDetails loadUserByUsername(String username)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)