我正在使用Spring Security进行登录授权。
在我的security-config.xml中,我正在使用以下代码:
<authentication-manager>
<authentication-provider>
<password-encoder hash="md5"/>
<jdbc-user-service data-source-ref="dataSource" users-by-
username-query="SELECT username, password,1 as enabled
FROM users WHERE username=?" authorities-by-
username-query="SELECT username, authority,1 as enabled
FROM users WHERE username =?" />
</authentication-provider>
</authentication-manager>
但是在我的数据库中,我已经使用自定义功能(不是纯md5哈希)使用了加密密码。
我的问题是我可以从我的security-config.xml中调用此函数,而不是
<password-encoder hash="md5"/>
还是还有其他方法?
先感谢您。
最佳答案
您可以注册将调用您的自定义函数的自定义密码编码器(创建实现PasswordEncoder
的类)。
在您的XML中,更改:
<password-encoder hash="md5"/>
与:
<password-encoder ref="passwordEncoder">
哪个passwordEncoder是实现
PasswordEncoder
的类/ bean的名称。here或here的更多详细信息。
关于java - 在我的security-config.xml中引用特定的密码编码器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45304420/