当前位置:网站首页>Empty encoded password warning reason
Empty encoded password warning reason
2022-06-24 00:14:00 【XuDream】
Premise :
- Use SpringSecurity Rights management framework .
- Console prompts during login Empty encoded password.
Possible causes :
- Framework version conflict does not support .
- The database password sub segment is stored in the database without encoding and encryption at the time of registration .
- Incorrect use of entity class .
resolvent :
- Revised version .
- When a new user is added to the database, the foreground password is encoded and stored in the database , The method is below .
- Bear in mind , Login Class and implementation UserDetails The class of cannot be the same , Otherwise, the password will not be found . And inherit UserDetails In the class ,username and password Remember to return to the user in the database username and password.
Register encryption :
@Override
public Res register(LoginBody loginBody) {
String msg = "";
SysUser sysUserDb = baseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserName, loginBody.getUserName()));
if (sysUserDb != null) {
msg = " Save the user '" + loginBody.getUserName() + "' Failure , The registered account already exists ";
} else {
SysUser sysUser = new SysUser();
sysUser.setUserName(loginBody.getUserName());
sysUser.setNickName(loginBody.getUserName());
sysUser.setPassword(encryptPassword(loginBody.getPassword()));
int regFlag = baseMapper.insert(sysUser);
if (regFlag != 1) {
msg = " Registration failed , Please contact the system administrator ";
}
return Res.ok(" Registered successfully ");
}
return Res.failed(msg);
}
/** * Generate BCryptPasswordEncoder password * * @param password password * @return Encrypted string */
public static String encryptPassword(String password) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.encode(password);
}
Entity class :
Login entity class :
package com.spring.security.entity;
import lombok.Data;
/** * User login object * * @author ruoyi */
@Data
public class LoginBody {
/** * user name */
private String userName;
/** * User password */
private String password;
/** * Verification Code */
private String code;
/** * Unique identification */
private String uuid;
}
Login return entity class :
Be careful getUsername() and getPassword() Method
package com.spring.security.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Set;
/** * @author lenovo * @date 2022/6/20 */
@Data
public class LoginUser implements UserDetails {
/** * The user account */
private String userName;
/** * password * @return */
private String password;
/** * department ID */
private String deptId;
/** * User information */
private SysUser user;
/** * Permission list */
private Set<String> permissions;
/** * User unique identification */
private String token;
/** * Access permissions * @return */
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
/** * Get password * @return */
@Override
public String getPassword() {
return user.getPassword();
}
/** * Get user account * @return */
@Override
public String getUsername() {
return user.getUserName();
}
/** * Whether the account has expired * @return */
@Override
public boolean isAccountNonExpired() {
return true;
}
/** * Is the account locked * @return */
@Override
public boolean isAccountNonLocked() {
return true;
}
/** * Whether the voucher expires * @return */
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/** * Is it enabled? * @return */
@Override
public boolean isEnabled() {
return true;
}
public LoginUser(String deptId, SysUser user, Set<String> permissions)
{
this.deptId = deptId;
this.user = user;
this.permissions = permissions;
}
}
边栏推荐
- Tiktok practice ~ password retrieval
- Dart series: using generators in dart
- Vulnerability recurrence - redis vulnerability summary
- First week of summer vacation
- 人工智能技术岗位面试要注意什么?
- 如何利用數倉創建時序錶
- Dot and cross product
- Android AIDL:跨进程调用Service (AIDL Service),kotlininvoke函数
- How to get started with machine learning?
- Chaos engineering, learn about it
猜你喜欢

合成大西瓜小游戏微信小程序源码/微信游戏小程序源码

【面试经验包】面试被吊打经验总结(一)

CPU取指到发出控制、微程序控制原理详细过程

Keywords such as extern and struct

windows10安全模式进入循环蓝屏修复

【FreeRTOS】07 二值信号量、计数信号量

迷茫的测试/开发程序员,不同人有着不同的故事、有着不同的迷茫......

超标量处理器设计 姚永斌 第3章 虚拟存储器 --3.1~3.2 小节摘录

Detailed process from CPU fetching to sending control and microprogram control principle

What is the use of AI technology in the medical field?
随机推荐
AI技术在医学领域有什么用?
重载(Overload)和重写(Override)的区别?
SQL Server 中 GO 的用法
Complete collection of development environment configuration -- Visual Studio 2022 installation
Nice input edit box
What is the future development of palmprint recognition technology?
Test - use case - detail frenzy
The first open-source MySQL HTAP database in China will be released soon, and the three highlights will be informed in advance that shiatomics technology will launch heavily
元宇宙中的社会秩序
Android App bundle exploration, client development interview questions
NLP工程师是干什么的?工作内容是什么?
Return, const, volatile keywords
Tiktok practice ~ password retrieval
【红绿灯识别】基于matlab GUI红绿灯识别【含Matlab源码 1908期】
Batch renaming of images by MATLAB
SQL数据库:知识点汇总,期末不挂科
What is medical treatment? AI medical concept analysis AI
Solve the problem of project dependency red reporting
Android AIDL:跨进程调用Service (AIDL Service),kotlininvoke函数
Android App Bundle探索,客户端开发面试题目