From 7c31a4a5195d6c130252a7faac11c0e3a65e242c Mon Sep 17 00:00:00 2001 From: vainhope <845869847@qq.com> Date: Sat, 16 Apr 2022 16:49:44 +0800 Subject: [PATCH] [issue_363][Taier-all] fix user not login #363 --- .../com/dtstack/taier/common/constant/CommonConstant.java | 2 ++ .../main/java/com/dtstack/taier/develop/config/MvcConfig.java | 2 +- .../com/dtstack/taier/develop/config/ResponseAdvisor.java | 4 ++-- .../dtstack/taier/develop/interceptor/LoginInterceptor.java | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/taier-common/src/main/java/com/dtstack/taier/common/constant/CommonConstant.java b/taier-common/src/main/java/com/dtstack/taier/common/constant/CommonConstant.java index 9f5221d448..9409eda05b 100644 --- a/taier-common/src/main/java/com/dtstack/taier/common/constant/CommonConstant.java +++ b/taier-common/src/main/java/com/dtstack/taier/common/constant/CommonConstant.java @@ -21,6 +21,8 @@ public interface CommonConstant { String JOB_ID = "${jobId}"; + String LOGIN = "login"; + String DOWNLOAD_LOG = "/taier/developDownload/downloadJobLog?jobId=%s&taskType=%s&tenantId=%s"; } diff --git a/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/MvcConfig.java b/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/MvcConfig.java index af8d060e30..d576ed69ec 100644 --- a/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/MvcConfig.java +++ b/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/MvcConfig.java @@ -73,7 +73,7 @@ protected void addArgumentResolvers(List argument @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(loginInterceptor()).addPathPatterns("/^((?!login).)*$"); + registry.addInterceptor(loginInterceptor()).addPathPatterns("/**"); super.addInterceptors(registry); } diff --git a/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/ResponseAdvisor.java b/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/ResponseAdvisor.java index b273700f7d..1886d10b04 100644 --- a/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/ResponseAdvisor.java +++ b/taier-data-develop/src/main/java/com/dtstack/taier/develop/config/ResponseAdvisor.java @@ -17,16 +17,16 @@ import org.springframework.validation.BindingResult; import org.springframework.validation.FieldError; import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; import javax.validation.ConstraintViolationException; import javax.xml.bind.ValidationException; import java.util.List; -@ControllerAdvice("com.dtstack.taiger.develop.controller.*") +@RestControllerAdvice public class ResponseAdvisor implements ResponseBodyAdvice { private final static Logger LOGGER = LoggerFactory.getLogger(ResponseAdvisor.class); diff --git a/taier-data-develop/src/main/java/com/dtstack/taier/develop/interceptor/LoginInterceptor.java b/taier-data-develop/src/main/java/com/dtstack/taier/develop/interceptor/LoginInterceptor.java index c71dd66ae9..5963e8f158 100644 --- a/taier-data-develop/src/main/java/com/dtstack/taier/develop/interceptor/LoginInterceptor.java +++ b/taier-data-develop/src/main/java/com/dtstack/taier/develop/interceptor/LoginInterceptor.java @@ -18,6 +18,7 @@ package com.dtstack.taier.develop.interceptor; +import com.dtstack.taier.common.constant.CommonConstant; import com.dtstack.taier.common.exception.ErrorCode; import com.dtstack.taier.common.exception.RdosDefineException; import com.dtstack.taier.develop.utils.CookieUtil; @@ -36,6 +37,9 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { String requestURI = request.getRequestURI(); + if(requestURI.contains(CommonConstant.LOGIN)){ + return true; + } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{}:{}", requestURI, request.getParameterMap()); }