前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >There is no PasswordEncoder mapped for the id "null"

There is no PasswordEncoder mapped for the id "null"

作者头像
王小雷
发布2019-05-26 10:46:30
2.4K0
发布2019-05-26 10:46:30
举报
文章被收录于专栏:王小雷王小雷

1、问题描述:在写基于Spring cloud微服务的OAuth2认证服务时,因为Spring-Security从4+升级到5+,导致There is no PasswordEncoder mapped for the id “null”错误。

2、解决方案:

可在密码验证类中添加

代码语言:javascript
复制
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
  return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}

或者在xml配置文件中添加

代码语言:javascript
复制
<b:bean id="passwordEncoder"
        class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/>

Spring官方文

There is no PasswordEncoder mapped for the id "null"
There is no PasswordEncoder mapped for the id "null"

3、拓展:源码解读:Class PasswordEncoderFactories,Spring Security 5 新增加了多种密码加密方式。

当前版本5新增支持加密方式:

代码语言:javascript
复制
bcrypt - BCryptPasswordEncoder (Also used for encoding)
ldap - LdapShaPasswordEncoder
MD4 - Md4PasswordEncoder
MD5 - new MessageDigestPasswordEncoder("MD5")
noop - NoOpPasswordEncoder
pbkdf2 - Pbkdf2PasswordEncoder
scrypt - SCryptPasswordEncoder
SHA-1 - new MessageDigestPasswordEncoder("SHA-1")
SHA-256 - new MessageDigestPasswordEncoder("SHA-256")
sha256 - StandardPasswordEncoder
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年02月26日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、问题描述:在写基于Spring cloud微服务的OAuth2认证服务时,因为Spring-Security从4+升级到5+,导致There is no PasswordEncoder mapped for the id “null”错误。
  • 2、解决方案:
  • 3、拓展:源码解读:Class PasswordEncoderFactories,Spring Security 5 新增加了多种密码加密方式。
相关产品与服务
微服务引擎 TSE
微服务引擎(Tencent Cloud Service Engine)提供开箱即用的云上全场景微服务解决方案。支持开源增强的云原生注册配置中心(Zookeeper、Nacos 和 Apollo),北极星网格(腾讯自研并开源的 PolarisMesh)、云原生 API 网关(Kong)以及微服务应用托管的弹性微服务平台。微服务引擎完全兼容开源版本的使用方式,在功能、可用性和可运维性等多个方面进行增强。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档