Bad credentials问题解决

DEBUG mePasswordAuthenticationFilter - Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials

看到这个时最好检查一下依赖,配置文件,java中与加密的相关代码
检查后再看一下lo4j的日志
发现一个

 WARN  o.bcrypt.BCryptPasswordEncoder  - Encoded password does not look like BCrypt
2020-10-14 13:25:06,336 87043  [bio-1555-exec-3] DEBUG .dao.DaoAuthenticationProvider  - Authentication failed: password does not match stored value
2020-10-14 13:25:06,336 87043  [bio-1555-exec-3] DEBUG ort.DefaultListableBeanFactory  - Returning cached instance of singleton bean 'sqlSessionFactory'
2020-10-14 13:25:06,337 87044  [bio-1555-exec-3] DEBUG mePasswordAuthenticationFilter  - Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials

Encoded password does not look like BCrypt
下午练习时爆出这个错误
当你采用安全框架设置加密后,如果要登录,由于之前是没有加密的密码所以会导致数据库里面的密码和现在的所输入的密码加密就会不一样,这时候的解决方式就是用java编程的方式来获取加密后的密码,然后将数据库里面对应的密码进行更换就可以
下面是获取加密的密码

public class BCryptPasswordEncoderUtils {

    private static BCryptPasswordEncoder bCryptPasswordEncoder=new BCryptPasswordEncoder();
    public static String encoderPassword(String password){
        return  bCryptPasswordEncoder.encode(password);
    }
     public  static  void  main(String[] args){
        String password="159753";
        String pwd=encoderPassword(password);
         System.out.println(pwd);
     }
}

你可能感兴趣的:(Bad credentials问题解决)