解決衝突
This commit is contained in:
commit
cfcc9caf0f
@ -36,29 +36,30 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||||||
@Override
|
@Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
String url = request.getURI().toString();
|
String url = request.getPath().toString();
|
||||||
if (xssProperties.getExcludeUrls().contains(url)) {
|
return chain.filter(exchange);
|
||||||
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);
|
// String api_token = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TOKEN);
|
||||||
if (ObjectUtils.isEmpty(api_token) || ObjectUtils.isEmpty(api_type)) {
|
// String api_type = exchange.getRequest().getHeaders().getFirst(UserAuthContains.API_TYPE);
|
||||||
return Mono.error(new RuntimeException("未登录"));
|
// 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 -> {
|
// String key = RedisConstans.IOT_TOKEN.concat(api_token);
|
||||||
if (ttl == -1) {
|
// return reactiveRedisTemplate.getExpire(key).map(Duration::getSeconds).flatMap(ttl -> {
|
||||||
// 用户没登陆
|
// if (ttl == -1) {
|
||||||
return Mono.error(new RuntimeException("未登录"));
|
// // 用户没登陆
|
||||||
} else if (ttl <= 3600) {
|
// return Mono.error(new RuntimeException("未登录"));
|
||||||
// token 将要失效
|
// } else if (ttl <= 3600) {
|
||||||
return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange));
|
// // token 将要失效
|
||||||
} else {
|
// return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange));
|
||||||
// 正常登录
|
// } else {
|
||||||
return chain.filter(exchange);
|
// // 正常登录
|
||||||
}
|
// return chain.filter(exchange);
|
||||||
});
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -30,15 +30,8 @@ spring:
|
|||||||
timeout: 5000
|
timeout: 5000
|
||||||
gateway:
|
gateway:
|
||||||
routes:
|
routes:
|
||||||
- id: user-api
|
- id: qiuguo-iot-box-user-api
|
||||||
uri: lb://user-api
|
uri: http://192.168.8.199:8080
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/device/**
|
- Path=/iot-user/**
|
||||||
- Path=/user/**
|
order: 1
|
||||||
- Path=/tuya/**
|
|
||||||
order: 1
|
|
||||||
- id: websocket-api
|
|
||||||
uri: lb://websocket-api
|
|
||||||
predicates:
|
|
||||||
- Path=/websocket/**
|
|
||||||
order: 2
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8081
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
@ -7,4 +7,3 @@ spring:
|
|||||||
application:
|
application:
|
||||||
name: qiuguo-iot-gateway
|
name: qiuguo-iot-gateway
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user