|
|
@@ -44,6 +44,11 @@ public class RequestCheckFilter implements Filter {
|
|
|
*/
|
|
|
private static final List<String> EXCLUDEPATH = new ArrayList<>();
|
|
|
|
|
|
+ /**
|
|
|
+ * 直接放行不需要校验token的请求
|
|
|
+ */
|
|
|
+ private static final List<String> IMPORT_PASS_PATH = new ArrayList<>();
|
|
|
+
|
|
|
/**
|
|
|
* 需要校验token但不用接口权限校验的请求
|
|
|
*/
|
|
|
@@ -61,6 +66,11 @@ public class RequestCheckFilter implements Filter {
|
|
|
if (StringUtils.isNotBlank(links)) {
|
|
|
EXCLUDEPATH.addAll(Arrays.asList(links.split(Global.COMMA)));
|
|
|
}
|
|
|
+
|
|
|
+ String importLinks = customConfig.getImportLinks();
|
|
|
+ if (StringUtils.isNotBlank(importLinks)) {
|
|
|
+ IMPORT_PASS_PATH.addAll(Arrays.asList(links.split(Global.COMMA)));
|
|
|
+ }
|
|
|
// String withoutLinks = customConfig.getWithoutLinks();
|
|
|
// if (StringUtils.isNotBlank(withoutLinks)) {
|
|
|
// WITHOUTPATH.addAll(Arrays.asList(withoutLinks.split(Global.COMMA)));
|
|
|
@@ -86,7 +96,7 @@ public class RequestCheckFilter implements Filter {
|
|
|
|
|
|
/*2、校验token**/
|
|
|
/*2.1、校验token非空*/
|
|
|
- HttpResult result = checkBlank(token, clientType, systemType, accessSpecial);
|
|
|
+ HttpResult result = checkBlank(token, clientType, systemType, accessSpecial, requestUri);
|
|
|
if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
ResponseUtil.writer(response, result);
|
|
|
return;
|
|
|
@@ -137,15 +147,15 @@ public class RequestCheckFilter implements Filter {
|
|
|
//redis 获取客户经理绑定企业ID
|
|
|
String managerKey = Global.getCustomerManagerUserLoginKey(SystemTypeEnum.MANAGE.getCode(), loginUserInfo.getId());
|
|
|
RSet<Object> set = RedissonUtils.getSet(managerKey);
|
|
|
- if (Objects.nonNull(set)){
|
|
|
+ if (Objects.nonNull(set)) {
|
|
|
List authUserIdList = JSONObject.parseObject(set.toString(), List.class);
|
|
|
- if(CollectionUtils.isNotEmpty(authUserIdList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(authUserIdList)) {
|
|
|
loginUserInfo.setAuthEntIdList(authUserIdList);
|
|
|
}
|
|
|
}
|
|
|
LoginUserHolder.set(loginUserInfo);
|
|
|
LoginEntHolder.set(loginEntInfo);
|
|
|
- RedissonUtils.putString(Global.getFullUserTokenKey(clientType , accessSpecial, userId), token, ClientTypeEnum.expireTime(clientType));
|
|
|
+ RedissonUtils.putString(Global.getFullUserTokenKey(clientType, accessSpecial, userId), token, ClientTypeEnum.expireTime(clientType));
|
|
|
RedissonUtils.putString(Global.getFullUserLoginKey(systemType, loginUserInfo.getId()), JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
|
|
|
RedissonUtils.putString(Global.getFullUserEntKey(loginEntInfo.getId()), JSON.toJSONString(loginEntInfo), Global.APP_TOKEN_EXPIRE);
|
|
|
filterChain.doFilter(servletRequest, servletResponse);
|
|
|
@@ -165,12 +175,12 @@ public class RequestCheckFilter implements Filter {
|
|
|
|
|
|
//校验用户企业审批状态
|
|
|
if (!loginEntInfo.getValid() && !REGISTER.equals(requestUri)) {
|
|
|
- if(loginEntInfo.getApproval() == Global.NO){
|
|
|
+ if (loginEntInfo.getApproval() == Global.NO) {
|
|
|
ResponseUtil.writer(response, HttpResult.error(HttpStatus.CODE_60603, HttpStatus.ENTCERTIFICATES_NOT_REGISTER));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(loginEntInfo.getApproval() == Global.NUMERICAL_THREE){
|
|
|
+ if (loginEntInfo.getApproval() == Global.NUMERICAL_THREE) {
|
|
|
ResponseUtil.writer(response, HttpResult.error(HttpStatus.CODE_60603, HttpStatus.ENTCERTIFICATES_NOT_PASS));
|
|
|
return;
|
|
|
}
|
|
|
@@ -211,16 +221,17 @@ public class RequestCheckFilter implements Filter {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param token token
|
|
|
- * @param clientType 客户端类型
|
|
|
- * @param systemType 系统类型
|
|
|
+ * @param token token
|
|
|
+ * @param clientType 客户端类型
|
|
|
+ * @param systemType 系统类型
|
|
|
* @param accessSpecial 专场标识
|
|
|
+ * @param requestUri 请求地址
|
|
|
* @return 校验结果
|
|
|
* @desc Hearder内容校验
|
|
|
* @author zk
|
|
|
* @date 2023/12/14
|
|
|
**/
|
|
|
- private HttpResult checkBlank(String token, String clientType, Integer systemType, String accessSpecial) {
|
|
|
+ private HttpResult checkBlank(String token, String clientType, Integer systemType, String accessSpecial, String requestUri) {
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.UN_LOGIN_MESSAGE);
|
|
|
}
|
|
|
@@ -230,8 +241,10 @@ public class RequestCheckFilter implements Filter {
|
|
|
if (StringUtils.isBlank(systemType)) {
|
|
|
return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.INVALID_REQUEST);
|
|
|
}
|
|
|
- if (StringUtils.isBlank(accessSpecial) && !Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode())) {
|
|
|
- return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.INVALID_REQUEST);
|
|
|
+ if (!IMPORT_PASS_PATH.contains(requestUri)) {
|
|
|
+ if (StringUtils.isBlank(accessSpecial) && !Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode())) {
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.INVALID_REQUEST);
|
|
|
+ }
|
|
|
}
|
|
|
accessSpecial = !Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode()) ? accessSpecial : null;
|
|
|
return HttpResult.ok();
|