diff --git a/iot-gateway/src/main/java/com/qiuguo/iot/gateway/filter/AuthFilter.java b/iot-gateway/src/main/java/com/qiuguo/iot/gateway/filter/AuthFilter.java index 3d9791d..bfcb409 100644 --- a/iot-gateway/src/main/java/com/qiuguo/iot/gateway/filter/AuthFilter.java +++ b/iot-gateway/src/main/java/com/qiuguo/iot/gateway/filter/AuthFilter.java @@ -36,29 +36,30 @@ public class AuthFilter implements GlobalFilter, Ordered { @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { ServerHttpRequest request = exchange.getRequest(); - String url = request.getURI().toString(); - if (xssProperties.getExcludeUrls().contains(url)) { - return chain.filter(exchange); - } - - String api_token = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TOKEN); - String api_type = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TYPE); - if (ObjectUtils.isEmpty(api_token) || ObjectUtils.isEmpty(api_type)) { - return Mono.error(new RuntimeException("未登录")); - } - String key = RedisConstans.IOT_TOKEN.concat(api_token); - return reactiveRedisTemplate.getExpire(key).map(Duration::getSeconds).flatMap(ttl -> { - if (ttl == -1) { - // 用户没登陆 - return Mono.error(new RuntimeException("未登录")); - } else if (ttl <= 3600) { - // token 将要失效 - return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange)); - } else { - // 正常登录 - return chain.filter(exchange); - } - }); + String url = request.getPath().toString(); + return chain.filter(exchange); + // if (xssProperties.getExcludeUrls().contains(url)) { + // return chain.filter(exchange); + // } + // + // String api_token = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TOKEN); + // String api_type = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TYPE); + // if (ObjectUtils.isEmpty(api_token) || ObjectUtils.isEmpty(api_type)) { + // return Mono.error(new RuntimeException("未登录")); + // } + // String key = RedisConstans.IOT_TOKEN.concat(api_token); + // return reactiveRedisTemplate.getExpire(key).map(Duration::getSeconds).flatMap(ttl -> { + // if (ttl == -1) { + // // 用户没登陆 + // return Mono.error(new RuntimeException("未登录")); + // } else if (ttl <= 3600) { + // // token 将要失效 + // return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange)); + // } else { + // // 正常登录 + // return chain.filter(exchange); + // } + // }); } diff --git a/iot-gateway/src/main/resources/bootstrap-dev.yml b/iot-gateway/src/main/resources/bootstrap-dev.yml index 0b442a0..6369bfa 100644 --- a/iot-gateway/src/main/resources/bootstrap-dev.yml +++ b/iot-gateway/src/main/resources/bootstrap-dev.yml @@ -30,15 +30,8 @@ spring: timeout: 5000 gateway: routes: - - id: user-api - uri: lb://user-api + - id: qiuguo-iot-box-user-api + uri: http://192.168.8.199:8080 predicates: - - Path=/device/** - - Path=/user/** - - Path=/tuya/** - order: 1 - - id: websocket-api - uri: lb://websocket-api - predicates: - - Path=/websocket/** - order: 2 \ No newline at end of file + - Path=/iot-user/** + order: 1 \ No newline at end of file diff --git a/iot-gateway/src/main/resources/bootstrap.yml b/iot-gateway/src/main/resources/bootstrap.yml index 14cc9ed..56c6651 100644 --- a/iot-gateway/src/main/resources/bootstrap.yml +++ b/iot-gateway/src/main/resources/bootstrap.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8081 spring: profiles: # 环境配置 @@ -7,4 +7,3 @@ spring: application: name: qiuguo-iot-gateway - diff --git a/iot-modules/iot-box-user-api/src/main/resources/bootstrap.yml b/iot-modules/iot-box-user-api/src/main/resources/bootstrap.yml index cb01af0..f811501 100644 --- a/iot-modules/iot-box-user-api/src/main/resources/bootstrap.yml +++ b/iot-modules/iot-box-user-api/src/main/resources/bootstrap.yml @@ -1,5 +1,6 @@ server: port: 8080 + spring: profiles: # 环境配置