在 Spring 中配置 NoOpPasswordEncoder [英] Configure NoOpPasswordEncoder in Spring
问题描述
我在 Spring 中有这个密码配置.
I have this configuration in Spring for passwords.
@Bean
public PasswordEncoder passwordEncoder() {
return NoOpPasswordEncoder.getInstance();
}
但看起来它已被弃用,我不需要加密其余密钥.我需要以纯文本形式存储它们.我该如何配置?
But looks like it's deprecated, I don't need to encrypt rest keys. I need to store them in plain text. How I can configure this?
推荐答案
虽然有点晚,但我发现了:
Though a little late, here is what I found:
如果你想以明文形式存储密码,你必须在它前面加上 {noop}
前缀.默认 PasswordEncoder
即 DelegatingPasswordEncoder
应该负责匹配它.例如如果您的明文密码是 abc123ABC
,则必须将其作为 {noop}abc123ABC
If you want to store the password as plaintext you will have to prefix it with {noop}
. Default PasswordEncoder
i.e DelegatingPasswordEncoder
should take care of matching it.
For e.g. if your plaintext password is abc123ABC
you will have to store it in database as {noop}abc123ABC
(适用于 Spring Security 5.x
以上)
这篇关于在 Spring 中配置 NoOpPasswordEncoder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!