【问题标题】:What is meant By 'WARN o.s.s.c.bcrypt.BCryptPasswordEncoder - Empty encoded password in spring security?'“WARN o.s.s.c.bcrypt.BCryptPasswordEncoder - Spring Security 中的空编码密码”是什么意思?
【发布时间】:2019-06-12 12:46:45
【问题描述】:

我正在现有的网络应用程序中实现 Spring Security,当我尝试登录时,我得到的响应是错误的凭据(即使凭据正确)当我尝试查看日志时,我得到的结果是

警告 o.s.s.c.bcrypt.BCryptPasswordEncoder - 空编码密码

这是凭证错误的原因吗?

这是我的代码

  @PostConstruct
public void init() {
    try {
        authenticationManagerBuilder
            .userDetailsService(accountDetailsService)
            .passwordEncoder(passwordEncoder());
    } catch (Exception e) {
        throw new BeanInitializationException("Security configuration failed", e);
    }
}


 @Bean
public PasswordEncoder passwordEncoder() 
{
    return new BCryptPasswordEncoder();
}

提前致谢!!

【问题讨论】:

标签: java spring-boot spring-security jwt


【解决方案1】:

字面意思就是字面意思。如有类似疑问,请查看源代码。

以下代码来自package org.springframework.security.crypto.bcrypt;

public boolean matches(CharSequence rawPassword, String encodedPassword) {
    if (encodedPassword == null || encodedPassword.length() == 0) {
        logger.warn("Empty encoded password");
        return false;
    }
    if (!BCRYPT_PATTERN.matcher(encodedPassword).matches()) {
        logger.warn("Encoded password does not look like BCrypt");
        return false;
    }
    return BCrypt.checkpw(rawPassword.toString(), encodedPassword);
}

如你所见:

encodedPassword == null ||编码密码.length() == 0

因此你的警告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    • 2014-04-23
    • 2015-03-29
    相关资源
    最近更新 更多