gpt4 book ai didi

java - jdbc-user-service 添加字段到 SQL

转载 作者:搜寻专家 更新时间:2023-10-31 20:22:51 24 4
gpt4 key购买 nike

这有点接近我之前的问题,但我一直在寻找如何去做

applicationContext-security.xml 中的当前代码:

<authentication-manager alias="authenticationManager">
<!-- DAO Based Security -->
<authentication-provider>
<password-encoder hash="sha-256" />
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT user_name AS username, user_password AS password, enabled FROM user where user_name=?"
authorities-by-username-query="SELECT user_name as username, R.name as authority FROM user U, roles R WHERE U.roles = R.Id AND user_name=?"/>
</authentication-provider>
</authentication-manager>

我想改变什么:

<authentication-manager alias="authenticationManager">
<!-- DAO Based Security -->
<authentication-provider>
<password-encoder hash="sha-256" />
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT user_name AS username, user_password AS password, id, location, userFirstName, userLastName, enabled FROM user where user_name=?"
authorities-by-username-query="SELECT user_name as username, R.name as authority FROM user U, roles R WHERE U.roles = R.Id AND user_name=?"/>
</authentication-provider>
</authentication-manager>

基本上我想从数据库中检索另外 4 个字段

我现在遇到的问题是我不知道我需要做什么,我已经尝试自定义 userDetails 和 userDetailsS​​ervice 但我似乎无法使用本网站的代码来实现它 http://www.theserverside.com/tip/-Spring-Security-Customizing-Your-User-and-Authorization-in

最佳答案

您不能使用原始的 org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl(即 jdbc-user-service 后面的类)来做到这一点。您需要对其进行子类化,或者需要实现您自己的完整 UserDetailsS​​ervice

关于java - jdbc-user-service 添加字段到 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8145991/

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