revert: 回退关闭验证码
回退关闭验证码
This commit is contained in:
@@ -28,11 +28,6 @@ public interface RedisConstants {
|
|||||||
*/
|
*/
|
||||||
String IP_QPS_THRESHOLD_LIMIT_KEY = "IP_QPS_THRESHOLD_LIMIT";
|
String IP_QPS_THRESHOLD_LIMIT_KEY = "IP_QPS_THRESHOLD_LIMIT";
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭验证码
|
|
||||||
*/
|
|
||||||
String CLOSE_CAPTCHA_KEY = "CLOSE_CAPTCHA";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机验证码缓存前缀
|
* 手机验证码缓存前缀
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class SecurityConfig {
|
|||||||
// 限流过滤器
|
// 限流过滤器
|
||||||
http.addFilterBefore(new RateLimiterFilter(redisTemplate, configService), UsernamePasswordAuthenticationFilter.class);
|
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 校验过滤器
|
// JWT 校验过滤器
|
||||||
http.addFilterBefore(new JwtValidationFilter(redisTemplate,securityProperties.getJwt().getKey()), UsernamePasswordAuthenticationFilter.class);
|
http.addFilterBefore(new JwtValidationFilter(redisTemplate,securityProperties.getJwt().getKey()), UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|
||||||
|
|||||||
@@ -36,12 +36,9 @@ public class CaptchaValidationFilter extends OncePerRequestFilter {
|
|||||||
|
|
||||||
private final CodeGenerator codeGenerator;
|
private final CodeGenerator codeGenerator;
|
||||||
|
|
||||||
private final ConfigService configService;
|
public CaptchaValidationFilter(RedisTemplate<String, Object> redisTemplate, CodeGenerator codeGenerator) {
|
||||||
|
|
||||||
public CaptchaValidationFilter(RedisTemplate<String, Object> redisTemplate, CodeGenerator codeGenerator, ConfigService configService) {
|
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
this.codeGenerator = codeGenerator;
|
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 {
|
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
|
||||||
// 检验登录接口的验证码
|
// 检验登录接口的验证码
|
||||||
if (LOGIN_PATH_REQUEST_MATCHER.matches(request)) {
|
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);
|
String captchaCode = request.getParameter(CAPTCHA_CODE_PARAM_NAME);
|
||||||
// TODO 兼容没有验证码的版本(线上请移除这个判断)
|
// TODO 兼容没有验证码的版本(线上请移除这个判断)
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
private final AuthService authService;
|
private final AuthService authService;
|
||||||
private final ConfigService configService;
|
|
||||||
|
|
||||||
@Operation(summary = "登录")
|
@Operation(summary = "登录")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@@ -56,10 +55,4 @@ public class AuthController {
|
|||||||
CaptchaResult captcha = authService.getCaptcha();
|
CaptchaResult captcha = authService.getCaptcha();
|
||||||
return Result.success(captcha);
|
return Result.success(captcha);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取是否关闭验证码")
|
|
||||||
@GetMapping("/captcha/unable")
|
|
||||||
public Result<Boolean> isCaptchaEnable() {
|
|
||||||
return Result.success(configService.getBooleanConfig(RedisConstants.CLOSE_CAPTCHA_KEY));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,4 @@ public interface ConfigService extends IService<Config> {
|
|||||||
*/
|
*/
|
||||||
Object getSystemConfig(String key);
|
Object getSystemConfig(String key);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取系统配置
|
|
||||||
* @param key 配置键
|
|
||||||
* @return 配置值
|
|
||||||
*/
|
|
||||||
boolean getBooleanConfig(String key);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,15 +159,4 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取系统配置
|
|
||||||
* @param key 配置键
|
|
||||||
* @return 配置值
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean getBooleanConfig(String key) {
|
|
||||||
Object systemConfig = getSystemConfig(key);
|
|
||||||
return systemConfig != null && Boolean.parseBoolean(systemConfig.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ security:
|
|||||||
- /swagger-ui/**
|
- /swagger-ui/**
|
||||||
- /swagger-ui.html
|
- /swagger-ui.html
|
||||||
- /api/v1/auth/captcha
|
- /api/v1/auth/captcha
|
||||||
- /api/v1/auth/captcha/unable
|
|
||||||
- /ws/**
|
- /ws/**
|
||||||
|
|
||||||
# 文件存储配置
|
# 文件存储配置
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ security:
|
|||||||
- /swagger-ui/**
|
- /swagger-ui/**
|
||||||
- /swagger-ui.html
|
- /swagger-ui.html
|
||||||
- /api/v1/auth/captcha
|
- /api/v1/auth/captcha
|
||||||
- /api/v1/auth/captcha/unable
|
|
||||||
- /ws/**
|
- /ws/**
|
||||||
|
|
||||||
# 文件存储配置
|
# 文件存储配置
|
||||||
|
|||||||
Reference in New Issue
Block a user