forked from Gitlink/microservices
feat(微服务治理工具): 优化portainer转发逻辑
修复拦截portainer中URL中携带endpoints的请求时,未考虑endpoints在末尾的情况 Signed-off-by: OTTO <731554297@qq.com>
This commit is contained in:
parent
c179173b74
commit
4c8be09a72
|
|
@ -132,8 +132,8 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
JSONObject resJson = JSONObject.parseObject(resStr);
|
||||
if (resJson.containsKey("message")) {
|
||||
String message = resJson.getString("message");
|
||||
log.error("Portainer鉴权异常,已清理redis中Portainer token");
|
||||
if (StringUtils.isNotBlank(message) && message.contains("A valid authorisation token is missing")) {
|
||||
log.error("Portainer鉴权异常,已清理redis中Portainer token");
|
||||
//token失效清除redis缓存
|
||||
redisService.deleteObject(CacheConstants.PORTAINER_TOKEN);
|
||||
bytes = JSON.toJSONBytes(AjaxResult.error(ExceptionMsgConstants.RETRY_ERROR));
|
||||
|
|
|
|||
|
|
@ -150,10 +150,10 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
if (lowerUrl.startsWith("/portainer")) {
|
||||
// 处理portainer指定endpoints的问题
|
||||
if (lowerUrl.startsWith("/portainer/api/endpoints/")) {
|
||||
String regex = "^/portainer/api/endpoints/\\d+/.*$";
|
||||
String regex = "^/portainer/api/endpoints/\\d+(/?.*)";
|
||||
if (Pattern.matches(regex, lowerUrl)) {
|
||||
// 替换掉endpoints
|
||||
regex = "(^/portainer/api/endpoints/)(\\d+)(/.*$)";
|
||||
regex = "(^/portainer/api/endpoints/)(\\d+)(/?.*)";
|
||||
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
if (matcher.find()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue