|
@@ -60,7 +60,8 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
@Override
|
|
@Override
|
|
public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain gatewayFilterChain) {
|
|
public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain gatewayFilterChain) {
|
|
log.info("check token and url permission....");
|
|
log.info("check token and url permission....");
|
|
- LinkedHashSet requiredAttribute = serverWebExchange.getRequiredAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
|
|
|
|
|
|
+ LinkedHashSet requiredAttribute
|
|
|
|
+ = serverWebExchange.getRequiredAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
|
|
ServerHttpRequest request = serverWebExchange.getRequest();
|
|
ServerHttpRequest request = serverWebExchange.getRequest();
|
|
String requestUri = request.getPath().pathWithinApplication().value();
|
|
String requestUri = request.getPath().pathWithinApplication().value();
|
|
String serviceName = "";
|
|
String serviceName = "";
|
|
@@ -70,7 +71,8 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
URI next = iterator.next();
|
|
URI next = iterator.next();
|
|
if (next.getPath().startsWith(GATE_WAY_PREFIX)) {
|
|
if (next.getPath().startsWith(GATE_WAY_PREFIX)) {
|
|
requestUri = next.getPath().substring(GATE_WAY_PREFIX.length());
|
|
requestUri = next.getPath().substring(GATE_WAY_PREFIX.length());
|
|
- serviceName = requestUri.substring(requestUri.indexOf('/') + 1, requestUri.indexOf('/', 2));
|
|
|
|
|
|
+ serviceName = requestUri.substring(requestUri.indexOf('/') + 1,
|
|
|
|
+ requestUri.indexOf('/', 2));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -90,9 +92,6 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
Map<String, Long> serviceFilters = this.dealServiceFilter();
|
|
Map<String, Long> serviceFilters = this.dealServiceFilter();
|
|
if (serviceFilters.get(serviceName) != null) {
|
|
if (serviceFilters.get(serviceName) != null) {
|
|
String appkey = request.getHeaders().getFirst("appKeyId");
|
|
String appkey = request.getHeaders().getFirst("appKeyId");
|
|
@@ -104,7 +103,7 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
Long curTime = new Date().getTime();
|
|
Long curTime = new Date().getTime();
|
|
// 防伪码主要是为了防止别人窃取url地址后直接长期使用,这边设了失效,目前暂定为24小时
|
|
// 防伪码主要是为了防止别人窃取url地址后直接长期使用,这边设了失效,目前暂定为24小时
|
|
// 前端实时获取当前时间跟系统时间作比较,如果时差超出24小时将会抛异常
|
|
// 前端实时获取当前时间跟系统时间作比较,如果时差超出24小时将会抛异常
|
|
- if((curTime - time) > 1000 * 3600 * 24) {
|
|
|
|
|
|
+ if ((curTime - time) > 1000 * 3600 * 24) {
|
|
RespDTO respDTO = new RespDTO();
|
|
RespDTO respDTO = new RespDTO();
|
|
respDTO.code = CommonErrorCode.SECURITYCODE_ERROR.getCode();
|
|
respDTO.code = CommonErrorCode.SECURITYCODE_ERROR.getCode();
|
|
respDTO.msg = CommonErrorCode.SECURITYCODE_ERROR.getMsg();
|
|
respDTO.msg = CommonErrorCode.SECURITYCODE_ERROR.getMsg();
|