使用postgresql时获取“编码的密码看起来不像bcrypt”

eufgjt7s  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(218)

我在springboot2中有一个使用bcrypt加密注册和登录用户的代码。当我使用mysql作为数据库时,一切正常,但当我将数据库更改为postgresql时,我可以注册以bcrypt格式存储的用户和密码,但在登录过程中,我收到这样的警告:“编码的密码看起来不像bcrypt”,无法登录数据库。
这是我的安全配置文件:

protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests()
        .
        .
        .
        .formLogin()
            .loginPage("/showLoginPage")
            .loginProcessingUrl("/authenticateTheUser")
            .successHandler(customAuthenticationSuccessHandler)
            .permitAll()
        .and()
        .logout().permitAll()
        .and()
        .exceptionHandling().accessDeniedPage("/access-denied");

}

//beans
//bcrypt bean definition
@Bean
public BCryptPasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}

//authenticationProvider bean definition
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider auth = new DaoAuthenticationProvider();
    auth.setUserDetailsService(userService); //set the custom user details service
    auth.setPasswordEncoder(passwordEncoder()); //set the password encoder - bcrypt
    return auth;
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题