Merge branch 'master' of gitee.com:youlaiorg/youlai-boot
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
<p align="center">
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/Java -17-brightgreen.svg"/>
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/SpringBoot-3.2.0-green.svg"/>
|
||||
<img alt="有来技术" src="https://img.shields.io/badge/SpringBoot-3.2.1-green.svg"/>
|
||||
<a href="https://gitee.com/youlaitech/youlai-boot" target="_blank">
|
||||
<img alt="有来技术" src="https://gitee.com/youlaiorg/youlai-boot/badge/star.svg"/>
|
||||
</a>
|
||||
|
||||
10
pom.xml
10
pom.xml
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.0</version> <!-- lookup parent from repository -->
|
||||
<version>3.2.1</version> <!-- lookup parent from repository -->
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<druid.version>1.2.16</druid.version>
|
||||
<mybatis-plus.version>3.5.4.1</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.5.5</mybatis-plus.version>
|
||||
|
||||
<knife4j.version>4.3.0</knife4j.version>
|
||||
|
||||
@@ -121,12 +121,6 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface CacheConstants {
|
||||
/**
|
||||
* 黑名单Token缓存前缀
|
||||
*/
|
||||
String BLACKLIST_TOKEN_PREFIX = "blacklist_token:";
|
||||
String BLACKLIST_TOKEN_PREFIX = "token:blacklist:";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,25 +4,24 @@ package com.youlai.system.common.enums;
|
||||
* EasyCaptcha 验证码类型枚举
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2023/03/24
|
||||
* @since 2.5.1
|
||||
*/
|
||||
public enum CaptchaTypeEnum {
|
||||
|
||||
/**
|
||||
* 算数
|
||||
* 圆圈干扰验证码
|
||||
*/
|
||||
ARITHMETIC,
|
||||
CIRCLE,
|
||||
/**
|
||||
* 中文
|
||||
*/
|
||||
CHINESE,
|
||||
/**
|
||||
* 中文闪图
|
||||
*/
|
||||
CHINESE_GIF,
|
||||
/**
|
||||
* 闪图
|
||||
* GIF验证码
|
||||
*/
|
||||
GIF,
|
||||
SPEC
|
||||
/**
|
||||
* 干扰线验证码
|
||||
*/
|
||||
LINE,
|
||||
/**
|
||||
* 扭曲干扰验证码
|
||||
*/
|
||||
SHEAR
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.captcha.generator.CodeGenerator;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.youlai.system.common.constant.CacheConstants;
|
||||
import com.youlai.system.common.enums.CaptchaTypeEnum;
|
||||
import com.youlai.system.core.security.jwt.JwtTokenProvider;
|
||||
import com.youlai.system.model.dto.CaptchaResult;
|
||||
import com.youlai.system.model.dto.LoginResult;
|
||||
@@ -14,6 +15,7 @@ import com.youlai.system.service.AuthService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
@@ -35,6 +37,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
|
||||
private final AuthenticationManager authenticationManager;
|
||||
@@ -73,6 +76,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
Claims claims = jwtTokenProvider.getTokenClaims(token);
|
||||
String jti = claims.get("jti", String.class);
|
||||
|
||||
Date expiration = claims.getExpiration();
|
||||
if (expiration != null) {
|
||||
long ttl = expiration.getTime() - System.currentTimeMillis();
|
||||
@@ -92,23 +96,23 @@ public class AuthServiceImpl implements AuthService {
|
||||
@Override
|
||||
public CaptchaResult getCaptcha() {
|
||||
|
||||
String type = captchaProperties.getType();
|
||||
String captchaType = captchaProperties.getType();
|
||||
int width = captchaProperties.getWidth();
|
||||
int height = captchaProperties.getHeight();
|
||||
int interfereCount = captchaProperties.getInterfereCount();
|
||||
int codeLength = captchaProperties.getCode().getLength();
|
||||
|
||||
AbstractCaptcha captcha;
|
||||
if ("circle".equalsIgnoreCase(type)) {
|
||||
if (CaptchaTypeEnum.CIRCLE.name().equalsIgnoreCase(captchaType)) {
|
||||
captcha = CaptchaUtil.createCircleCaptcha(width, height, codeLength, interfereCount);
|
||||
} else if ("gif".equalsIgnoreCase(type)) {
|
||||
} else if (CaptchaTypeEnum.GIF.name().equalsIgnoreCase(captchaType)) {
|
||||
captcha = CaptchaUtil.createGifCaptcha(width, height, codeLength);
|
||||
} else if ("line".equalsIgnoreCase(type)) {
|
||||
} else if (CaptchaTypeEnum.LINE.name().equalsIgnoreCase(captchaType)) {
|
||||
captcha = CaptchaUtil.createLineCaptcha(width, height, codeLength, interfereCount);
|
||||
} else if ("shear".equalsIgnoreCase(type)) {
|
||||
} else if (CaptchaTypeEnum.SHEAR.name().equalsIgnoreCase(captchaType)) {
|
||||
captcha = CaptchaUtil.createShearCaptcha(width, height, codeLength, interfereCount);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid captcha type: " + type);
|
||||
throw new IllegalArgumentException("Invalid captcha type: " + captchaType);
|
||||
}
|
||||
captcha.setGenerator(codeGenerator);
|
||||
captcha.setTextAlpha(captchaProperties.getTextAlpha());
|
||||
|
||||
Reference in New Issue
Block a user