|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.RedisKey;
|
|
import com.fdkankan.common.constant.RedisKey;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
@@ -49,19 +50,19 @@ public class AppAuthFilter implements GatewayFilter, Ordered {
|
|
//先获取校验app id的合法性
|
|
//先获取校验app id的合法性
|
|
String developerJson = redisTemplate.opsForValue().get(String.format(RedisKey.TM_DEVELOPER, appId));
|
|
String developerJson = redisTemplate.opsForValue().get(String.format(RedisKey.TM_DEVELOPER, appId));
|
|
if(StrUtil.isBlank(developerJson)){
|
|
if(StrUtil.isBlank(developerJson)){
|
|
- throw new BusinessException(ServerCode.APP_ID_ILLEGAL);
|
|
|
|
|
|
+ throw new BusinessException(ErrorCode.APP_ID_ILLEGAL);
|
|
}
|
|
}
|
|
//校验token的有效性
|
|
//校验token的有效性
|
|
TmDeveloperDto tmDeveloperDto = JSONUtil.toBean(developerJson, TmDeveloperDto.class);
|
|
TmDeveloperDto tmDeveloperDto = JSONUtil.toBean(developerJson, TmDeveloperDto.class);
|
|
String tmpToken = tmDeveloperDto.getAppId() + tmDeveloperDto.getAppSecret() + timeStamp.toString();
|
|
String tmpToken = tmDeveloperDto.getAppId() + tmDeveloperDto.getAppSecret() + timeStamp.toString();
|
|
String enCodeToken = SHAUtils.getSHA256(tmpToken);
|
|
String enCodeToken = SHAUtils.getSHA256(tmpToken);
|
|
if(!StrUtil.equals(enCodeToken , token)){
|
|
if(!StrUtil.equals(enCodeToken , token)){
|
|
- throw new BusinessException(ServerCode.TOKEN_ILLEGAL);
|
|
|
|
|
|
+ throw new BusinessException(ErrorCode.TOKEN_ILLEGAL);
|
|
}
|
|
}
|
|
//校验数据是否已经被串改放到controller里面校验
|
|
//校验数据是否已经被串改放到controller里面校验
|
|
log.info("------网关基础校验通过-------");
|
|
log.info("------网关基础校验通过-------");
|
|
}else{
|
|
}else{
|
|
- throw new BusinessException(ServerCode.PARAM_REQUIRED);
|
|
|
|
|
|
+ throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
}
|
|
}
|
|
return chain.filter(exchange);
|
|
return chain.filter(exchange);
|
|
}
|
|
}
|