chore: continew-starter 2.7.3 => 2.7.4

This commit is contained in:
2024-11-18 23:19:34 +08:00
parent 4454daa9e0
commit 66f55cdf70
34 changed files with 75 additions and 89 deletions

View File

@@ -21,6 +21,7 @@ import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.sign.SaSignTemplate;
import cn.dev33.satoken.sign.SaSignUtil;
import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
@@ -29,10 +30,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.continew.admin.common.context.UserContext;
import top.continew.admin.common.context.UserContextHolder;
import top.continew.admin.open.sign.OpenSignTemplate;
import top.continew.admin.open.sign.OpenApiSignTemplate;
import top.continew.starter.auth.satoken.autoconfigure.SaTokenExtensionProperties;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.core.exception.BusinessException;
import top.continew.starter.core.validation.CheckUtils;
import java.util.List;
@@ -40,6 +42,7 @@ import java.util.List;
* Sa-Token 配置
*
* @author Charles7c
* @author chengzi
* @since 2022/12/19 22:13
*/
@Configuration
@@ -48,7 +51,7 @@ public class SaTokenConfiguration {
private final SaTokenExtensionProperties properties;
private final LoginPasswordProperties loginPasswordProperties;
private final OpenSignTemplate openSignTemplate;
private final OpenApiSignTemplate signTemplate;
/**
* Sa-Token 权限认证配置
@@ -63,31 +66,28 @@ public class SaTokenConfiguration {
*/
@Bean
public SaInterceptor saInterceptor() {
SaManager.setSaSignTemplate(openSignTemplate);
SaManager.setSaSignTemplate(signTemplate);
return new SaExtensionInterceptor(handle -> SaRouter.match(StringConstants.PATH_PATTERN)
.notMatch(properties.getSecurity().getExcludes())
.check(r -> {
// 拦截验证sign
// 判断是否包含sign参数
// 如果包含 sign进行 API 接口参数签名验证
SaRequest saRequest = SaHolder.getRequest();
List<String> paramNames = saRequest.getParamNames();
boolean matchParamSign = paramNames.stream().anyMatch(paramName -> paramName.equals("sign"));
// 如果包含sign参数走SaToken API接口参数签名验证
if (matchParamSign) {
if (paramNames.stream().anyMatch(SaSignTemplate.sign::equals)) {
try {
SaSignUtil.checkRequest(saRequest);
} catch (Exception e) {
CheckUtils.throwIf(true, e.getMessage());
throw new BusinessException(e.getMessage());
}
} else {
// 如果不包含sign参数走登录token验证
StpUtil.checkLogin();
if (SaRouter.isMatchCurrURI(loginPasswordProperties.getExcludes())) {
return;
}
UserContext userContext = UserContextHolder.getContext();
CheckUtils.throwIf(userContext.isPasswordExpired(), "密码已过期,请修改密码");
return;
}
// 不包含 sign 参数,进行普通登录验证
StpUtil.checkLogin();
if (SaRouter.isMatchCurrURI(loginPasswordProperties.getExcludes())) {
return;
}
UserContext userContext = UserContextHolder.getContext();
CheckUtils.throwIf(userContext.isPasswordExpired(), "密码已过期,请修改密码");
}));
}
}

View File

@@ -42,7 +42,7 @@ import top.continew.admin.system.model.resp.user.UserDetailResp;
import top.continew.admin.system.service.UserService;
import top.continew.starter.cache.redisson.util.RedisUtils;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.log.core.annotation.Log;
import java.util.List;

View File

@@ -34,7 +34,7 @@ import top.continew.admin.auth.model.resp.LoginResp;
import top.continew.admin.auth.model.resp.SocialAuthAuthorizeResp;
import top.continew.admin.auth.service.LoginService;
import top.continew.starter.core.exception.BadRequestException;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.log.core.annotation.Log;
/**

View File

@@ -54,8 +54,8 @@ import top.continew.starter.cache.redisson.util.RedisUtils;
import top.continew.starter.captcha.graphic.core.GraphicCaptchaService;
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.continew.starter.core.util.TemplateUtils;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.CheckUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.log.core.annotation.Log;
import top.continew.starter.messaging.mail.util.MailUtils;
import top.continew.starter.security.limiter.annotation.RateLimiter;

View File

@@ -35,7 +35,7 @@ import top.continew.admin.system.enums.OptionCategoryEnum;
import top.continew.admin.system.model.query.*;
import top.continew.admin.system.model.resp.FileUploadResp;
import top.continew.admin.system.service.*;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.log.core.annotation.Log;

View File

@@ -36,7 +36,7 @@ import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp;
import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp;
import top.continew.admin.system.model.resp.dashboard.DashboardOverviewCommonResp;
import top.continew.admin.system.service.DashboardService;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.log.core.annotation.Log;
import java.io.IOException;

View File

@@ -32,7 +32,7 @@ import cn.dev33.satoken.stp.StpUtil;
import top.continew.admin.auth.model.query.OnlineUserQuery;
import top.continew.admin.auth.model.resp.OnlineUserResp;
import top.continew.admin.auth.service.OnlineUserService;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.core.validation.CheckUtils;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;

View File

@@ -29,7 +29,7 @@ import top.continew.admin.system.model.resp.MenuResp;
import top.continew.admin.system.service.MenuService;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.core.util.URLUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;

View File

@@ -27,7 +27,7 @@ import top.continew.admin.system.model.req.NoticeReq;
import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.service.NoticeService;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;

View File

@@ -45,7 +45,7 @@ import top.continew.admin.system.service.UserService;
import top.continew.admin.system.service.UserSocialService;
import top.continew.starter.cache.redisson.util.RedisUtils;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import java.io.IOException;
import java.util.List;

View File

@@ -42,7 +42,7 @@ import top.continew.admin.system.model.resp.user.UserImportResp;
import top.continew.admin.system.model.resp.user.UserResp;
import top.continew.admin.system.service.UserService;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;

View File

@@ -5,5 +5,5 @@
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
:: ${project.name} :: v${project.version}
:: ContiNew Starter :: v2.7.3
:: ContiNew Starter :: v2.7.4
:: Spring Boot :: v${spring-boot.version}