revert: 回退关闭验证码

回退关闭验证码
This commit is contained in:
胡少翔
2024-09-18 11:32:31 +08:00
parent b00b3c6868
commit bcc30a6bee
8 changed files with 2 additions and 41 deletions

View File

@@ -28,11 +28,6 @@ public interface RedisConstants {
*/
String IP_QPS_THRESHOLD_LIMIT_KEY = "IP_QPS_THRESHOLD_LIMIT";
/**
* 关闭验证码
*/
String CLOSE_CAPTCHA_KEY = "CLOSE_CAPTCHA";
/**
* 手机验证码缓存前缀
*/

View File

@@ -68,7 +68,7 @@ public class SecurityConfig {
// 限流过滤器
http.addFilterBefore(new RateLimiterFilter(redisTemplate, configService), UsernamePasswordAuthenticationFilter.class);
// 验证码校验过滤器
http.addFilterBefore(new CaptchaValidationFilter(redisTemplate, codeGenerator,configService), UsernamePasswordAuthenticationFilter.class);
http.addFilterBefore(new CaptchaValidationFilter(redisTemplate, codeGenerator), UsernamePasswordAuthenticationFilter.class);
// JWT 校验过滤器
http.addFilterBefore(new JwtValidationFilter(redisTemplate,securityProperties.getJwt().getKey()), UsernamePasswordAuthenticationFilter.class);

View File

@@ -36,12 +36,9 @@ public class CaptchaValidationFilter extends OncePerRequestFilter {
private final CodeGenerator codeGenerator;
private final ConfigService configService;
public CaptchaValidationFilter(RedisTemplate<String, Object> redisTemplate, CodeGenerator codeGenerator, ConfigService configService) {
public CaptchaValidationFilter(RedisTemplate<String, Object> redisTemplate, CodeGenerator codeGenerator) {
this.redisTemplate = redisTemplate;
this.codeGenerator = codeGenerator;
this.configService = configService;
}
@@ -49,11 +46,6 @@ public class CaptchaValidationFilter extends OncePerRequestFilter {
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
// 检验登录接口的验证码
if (LOGIN_PATH_REQUEST_MATCHER.matches(request)) {
// 关闭验证码校验
if (configService.getBooleanConfig(RedisConstants.CLOSE_CAPTCHA_KEY)) {
chain.doFilter(request, response);
return;
}
// 请求中的验证码
String captchaCode = request.getParameter(CAPTCHA_CODE_PARAM_NAME);
// TODO 兼容没有验证码的版本(线上请移除这个判断)

View File

@@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.*;
public class AuthController {
private final AuthService authService;
private final ConfigService configService;
@Operation(summary = "登录")
@PostMapping("/login")
@@ -56,10 +55,4 @@ public class AuthController {
CaptchaResult captcha = authService.getCaptcha();
return Result.success(captcha);
}
@Operation(summary = "获取是否关闭验证码")
@GetMapping("/captcha/unable")
public Result<Boolean> isCaptchaEnable() {
return Result.success(configService.getBooleanConfig(RedisConstants.CLOSE_CAPTCHA_KEY));
}
}

View File

@@ -65,10 +65,4 @@ public interface ConfigService extends IService<Config> {
*/
Object getSystemConfig(String key);
/**
* 获取系统配置
* @param key 配置键
* @return 配置值
*/
boolean getBooleanConfig(String key);
}

View File

@@ -159,15 +159,4 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
return null;
}
/**
* 获取系统配置
* @param key 配置键
* @return 配置值
*/
@Override
public boolean getBooleanConfig(String key) {
Object systemConfig = getSystemConfig(key);
return systemConfig != null && Boolean.parseBoolean(systemConfig.toString());
}
}