1、跳过密码校验
实现原理是从库中查询出密码,直接用库中密码跳过加密进行密码比较。
重写DaoAuthenticationProvider.java密码校验方法

package com.zscq.framework.provider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
public class LoginAuthenticationProvider extends DaoAuthenticationProvider {
public LoginAuthenticationProvider(UserDetailsService userDetailsService) {
super();
// 这个地方一定要对userDetailsService赋值,不然userDetailsService是null (这个坑有点深)
setUserDetailsService(userDetailsService);
}
@SuppressWarnings("deprecation")
protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
if (authentication.getCr

本文介绍了一种绕过传统密码验证的方法,通过直接比较数据库中的明文密码来实现登录验证,并调整了相关配置以确保系统的安全性。此外,还介绍了如何在应用中禁用Swagger,以减少潜在的安全风险。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



