springboot 2.x升级后出现Spring Security – There is no PasswordEncoder mapped for the id “null”的解决方案
异常描述:
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”
at org.springframework.security.crypto.password.
DelegatingPasswordEncoder$UnmappedIdPasswordEncoder.matches(DelegatingPasswordEncoder.java:244)~[spring-security-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]at org.springframework.security.
crypto.password.DelegatingPasswordEncoder.matches(DelegatingPasswordEncoder.java:198)
~[spring-security-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
我们在这个异常中,可以看到主要原因是: There is no PasswordEncoder mapped for the id “null”
即我们在对密码进行编码的时候没有指定对应的密码编码器.这个原因是由于在spring security5中,密码的存储需要进行编码,所以需要添加编码格式,spring Security框架已经为我们定制好了一些默认编码器,我们只需要在代码中声明即可
出错的代码
@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {//基于内存管理的角色授权登录系统auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN"); }}
更改方法一,但由于不安全,官方不推荐 【指定了NoOpPasswordEncoder进行编码】
@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {//基于内存管理的角色授权登录系统auth.inMemoryAuthentication().withUser("admin").password("{noop}123456").roles("ADMIN"); }}
参考:
https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released#password-storage-format https://www.mkyong.com/spring-boot/spring-security-there-is-no-passwordencoder-mapped-for-the-id-null/
springboot 2.x升级后出现Spring Security – There is no PasswordEncoder mapped for the id “null”的解决方案相关推荐
- 关于Spring Security中显示There is no PasswordEncoder mapped for the id “null“的问题分析
关于Spring Security中显示There is no PasswordEncoder mapped for the id "null"的问题分析 1 Spring Sec ...
- Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”
编写好继承了WebSecurityConfigurerAdapter类的WebSecurityConfig类后,我们需要在configure(AuthenticationManagerBuilder ...
- Spring Security:密码编码器PasswordEncoder介绍与Debug分析
博主在之前已经介绍了Spring Security的用户UserDetails与用户服务UserDetailsService,本篇博客介绍Spring Security的密码编码器PasswordEn ...
- springboot 访问html_Spring Boot中使用Spring Security进行安全控制
我们在编写Web应用时,经常需要对页面做一些安全控制,比如:对于没有访问权限的用户需要转到登录表单页面.要实现访问控制的方法多种多样,可以通过Aop.拦截器实现,也可以通过框架实现(如:Apache ...
- Spring Boot + Mybatis——RowBoundsPlugin造成的[Mapped Statements collection already contains value]解决方案
基本概念 RowBoundsPlugin:通过ResultSet的游标实现的分页查询插件,容易出现性能问题 <plugin type="org.mybatis.generator.pl ...
- Spring Boot+Vue/前后端分离/高并发/秒杀实战课程之spring Security快速搭建oauth2 内存版身份认证
Springboot快速搭建oauth2 内存版身份认证 环境准备 点击[Create New Project]创建一个新的项目 项目环境配置 配置Thymeleaf 搭建oauth2认证,加入两个依 ...
- 31 | SpringBoot安全之整合Spring Security
一.安全 应用程序的两个主要区域是"认证"和"授权"(或者访问控制),这两个主要区域是安全的两个目标. 身份验证意味着确认您自己的身份,而授权意味着授予对系统的 ...
- SpringBoot第二十三篇:安全性之Spring Security
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/11350255.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言 系统的安全 ...
- SpringBoot 集成 Spring Security
Spring Security Spring Security是一个功能强大且高度可定制的身份验证和访问控制框架.它实际上是保护基于spring的应用程序的标准. Spring Security是一个 ...
最新文章
- swoole单台并发php,php swoole 并发多少?
- 南邮 AAencode
- 2020年快手短视频直播电商营销增长宝典
- SQLAlchemy Mapping Table Columns
- mysql连表删除语句_MySQL中联表更新与删除的语法介绍
- SQL语句详解(一)——基本增删改操作
- 【常见Web应用安全问题】---12、URL redirection
- 学习类App原型制作分享-Wokabulary
- 计算机硬盘驱动是什么,电脑重装系统时提示缺少硬盘驱动该怎么解决
- 常识:如何从大陆拨打国际长途电话到境外的方法
- php微信授权登录sdk,微信授权登录如何使用?总结微信授权登录实例用法
- CURL 发送请求详解
- 关于typora的天坑
- 针式个人知识管理系统帮助:实现您的PKM梦想!
- 计算机考研就业率,这8个考研专业,就业率一直居高不下,报了就是赚了!
- 目标检测算法——YOLOv5/YOLOv7改进之结合特征提取网络RFBNet(涨点明显)
- 微信点击链接直接下载安装包功能实现方式
- 看个小程序,测测你细心不细心
- 我是如何从屌丝程序员逆袭成为大厂总监的?
- 达人篇:6.3)试验设计DOE,Design of Experiments