首页 > 其他分享 >Spring Security 报:Encoded password does not look like BCrypt

Spring Security 报:Encoded password does not look like BCrypt

时间:2023-04-27 09:00:50浏览次数:34  
标签:Exception look Spring auth does Encoded password configure

SpringBoot 集成 Security 时,报 Encoded password does not look like BCrypt
原因:SecurityConfig 必须 Bean 的形式实例化

/**
 * 配置用户身份的configure()方法
 *
 * @param auth
 * @throws Exception
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}

解决方案

/**
 * 强散列哈希加密实现 
 * 必须 Bean 的形式实例化,否则会报 :Encoded password does not look like BCrypt
 */
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder()
{
    return new BCryptPasswordEncoder();
}

/**
 * 配置用户身份的configure()方法
 *
 * @param auth
 * @throws Exception
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
}

标签:Exception,look,Spring,auth,does,Encoded,password,configure
From: https://www.cnblogs.com/vipsoft/p/17353361.html

相关文章

  • SpringBoot 集成 SpringSecurity + MySQL + JWT 附源码,废话不多直接盘
    SpringBoot集成SpringSecurity+MySQL+JWT无太多理论,直接盘一般用于Web管理系统可以先看SpringBootSpringSecurity基于内存的使用介绍本文介绍如何整合SpringSecurity+MySQL+JWT数据结构数据库脚本:https://gitee.com/VipSoft/VipBoot/blob/develop/vipsoft-sec......
  • SpringBoot配置MongoDb
    MongoDb建表:MongoDB不需要建表,直接插入数据就会建表。日期用ISODate()转换。db.getCollection("mongoDbTest").insert({userId:"dxcefg",status:1,price:1.23,updateTime:ISODate("2022-02-13T07:06:25.371Z")})添加maven依赖:<dependency>......
  • SpringMcv 文件上传下载
    文件上传SpringMVC为文件上传提供了直接的支持,这种支持是通过即插即用的MultipartResolver实现的。Spring用JakartaCommonsFileUpload技术实现了一个MultipartResolver实现类:CommonsMultipartResovlerSpringMVC上下文中默认没有装配MultipartResovler,因此默认情况......
  • springboot自定义拦截器
    springboot自定义拦截器操作说明1、编写一个拦截器实现HandlerInterceptor接口2、拦截器注册到容器中(实现WebMvcConfigures的addInterceptors)3、指定拦截规则(如果是拦截所有,静态资源也会被拦截)LoginInterceptor.javapackagecom.example.springtxiangmu.interceptor;im......
  • spring jdbc 编程式事务
    所谓编程式事务指的是通过编码方式实现事务,即类似于JDBC编程实现事务管理。新建maven工程,pom文件如下:<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http:/......
  • spring aop 注解方式
    前置、后置、环绕、切面、切点packagecom.springinaction.springidol;importorg.aspectj.lang.ProceedingJoinPoint;importorg.aspectj.lang.annotation.AfterReturning;importorg.aspectj.lang.annotation.AfterThrowing;importorg.aspectj.lang.annotation.Around;imp......
  • spring aop xml方式
    工程如图:pom文件内容:<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd" xmlns......
  • spring jdbc 声明式事务
    Spring的声明式事务顾名思义就是采用声明的方式来处理事务。这里所说的声明,就是指在配置文件中申明。用在Spring配置文件中声明式的处理事务来代替代码式的处理事务。这样的好处是,事务管理不侵入开发的组件,具体来说,业务逻辑对象就不会意识到正在事务管理之中,事实上也应该如此,因为事......
  • SpringSecurity从入门到精通:认证成功处理器&认证失败处理器
    认证成功处理器  认证失败处理器  ......
  • [转]前端传嵌套对象参数给spring mvc
    在使用springmvc开发web应用时,感觉springmvc的controller方法能自动将参数注入到方法的参数对象中,极大的方便了开发。但是,在遇到有嵌套对象的时候,比如订单对象有个属性是用户对象,就不好处理了。一种情况是,传递的参数都是作为post方法的请求体,我们可以用RequestBody注解。但是当条......