java - “WARN osscbcrypt.BCryptPasswordEncoder - Spring Security 中的空编码密码”是什么意思?
问题描述
我正在现有的 Web 应用程序中实现 Spring Security,当我尝试登录时,我得到的响应是错误的凭据(即使凭据是正确的)当我尝试查看日志时,我得到了一些东西
警告 osscbcrypt.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();
}
提前致谢 !!
解决方案
从字面上看,它的意思是它所说的。如有类似疑问,请查看源代码。
下面的代码来自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);
}
如你看到的:
编码密码 == 空 || 编码密码.length() == 0
因此你的警告。
推荐阅读
- .net-core - .NET Core 2.1 SDK Linux x64 未找到可用版本的 libssl
- tensorflow - 如何计算多标签(不平衡数据)的类权重?
- awk - 根据模式在连续文本中插入换行符
- java - Spring Data 返回空实体
- arrays - 从数组 java 中的 i 字符串中选择 i char
- html - Fonduer max_storage_temp_tutorial 解析 html 文件时出错
- python - 如何在不使用包含 smartsheet sdk 的 python 编辑器的情况下运行 python 脚本
- swift - 如何判断某个路径是否存在符号链接?
- flutter - 如何将大小设置为 CircularProgressIndicator?
- jquery - JQuery Month 滑块不起作用