Commit ab15693b by 刘宇峰

优化代码

1 parent 9d27b0a5
......@@ -66,7 +66,7 @@ public class OpenApiAuthCheckFilter implements GlobalFilter, Ordered {
}
//跳过不符合需要验证的路径
if (StringUtils.isMatchedStr(openApiUrls, url)) {
if (!StringUtils.isMatchedStr(openApiUrls, url)) {
return chain.filter(exchange);
}
......@@ -95,8 +95,15 @@ public class OpenApiAuthCheckFilter implements GlobalFilter, Ordered {
}
};
DecodedJWT decodedJWT = null;
//解码Token
DecodedJWT decodedJWT = gatewayJwtUtils.decode(accessToken);
try {
decodedJWT = gatewayJwtUtils.decode(accessToken);
} catch (Exception e) {
log.error("解码Token失败,{}", e.toString());
// TODO: 2023/4/20 待优化下面返回封装统一方法
return exchange.getResponse().writeWith(Mono.just(exchange.getResponse().bufferFactory().wrap(JSON.toJSONString(OpenApiResult.failure("40003", "AccessToken Error.")).getBytes())));
}
String serName = decodedJWT.getClaim("name").asString();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!