|
@@ -6,9 +6,12 @@ import com.dragonsoft.approve.model.TokenInfo;
|
|
|
import com.dragonsoft.dcuc.approvegateway.Constants;
|
|
|
import com.dragonsoft.dcuc.approvegateway.business.BimBusiness;
|
|
|
import com.dragonsoft.dcuc.approvegateway.pojo.BimUserInfoItemRespVO;
|
|
|
+import com.dragonsoft.dcuc.approvegateway.properties.DcucApproveProperties;
|
|
|
import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
|
|
|
import com.dragonsoft.duceap.base.exception.ApplicationException;
|
|
|
import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
|
+import com.dragonsoft.duceap.commons.util.UrlMatcher;
|
|
|
+import com.dragonsoft.duceap.commons.util.json.JsonUtils;
|
|
|
import com.dragonsoft.duceap.security.jwt.JwtTokenUtils;
|
|
|
import com.dragonsoft.duceap.web.SecurityProperties;
|
|
|
import com.netflix.zuul.ZuulFilter;
|
|
@@ -17,6 +20,7 @@ import com.netflix.zuul.exception.ZuulException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.autoconfigure.web.ServerProperties;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -32,6 +36,12 @@ public class BimUserInfoPreFilter extends ZuulFilter {
|
|
|
@Autowired
|
|
|
private SecurityProperties securityProperties;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ServerProperties serverProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DcucApproveProperties dcucApproveProperties;
|
|
|
+
|
|
|
@Autowired
|
|
|
private BimBusiness bimBusiness;
|
|
|
|
|
@@ -54,6 +64,11 @@ public class BimUserInfoPreFilter extends ZuulFilter {
|
|
|
@Override
|
|
|
public Object run() throws ZuulException {
|
|
|
RequestContext ctx = RequestContext.getCurrentContext();
|
|
|
+ HttpServletRequest request = ctx.getRequest();
|
|
|
+ if (isNeedUserInfo(request)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
BaseSecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
logger.info("====登录用户信息:{}====", JSONObject.toJSONString(currentUser));
|
|
|
if (currentUser != null) {
|
|
@@ -89,4 +104,32 @@ public class BimUserInfoPreFilter extends ZuulFilter {
|
|
|
|
|
|
return baseSecurityUser;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否需要用户信息
|
|
|
+ *
|
|
|
+ * @param request 请求
|
|
|
+ * @return 是否需要
|
|
|
+ */
|
|
|
+ private boolean isNeedUserInfo(HttpServletRequest request) {
|
|
|
+ String contextPath = serverProperties.getServlet().getContextPath();
|
|
|
+ String requestUri = request.getRequestURI();
|
|
|
+ logger.debug("Security filter origin uri:{}", requestUri);
|
|
|
+
|
|
|
+ // 去除上下文
|
|
|
+ requestUri = requestUri.substring(contextPath.length());
|
|
|
+
|
|
|
+ logger.debug("Security filter not context uri:{}", requestUri);
|
|
|
+
|
|
|
+ String huaweiLoginFilterUrl = dcucApproveProperties.getHuaweiLoginFilterUrl();
|
|
|
+ String[] splitUrls = huaweiLoginFilterUrl.split(",");
|
|
|
+
|
|
|
+ logger.debug("splitUrls:{} .", JsonUtils.toJSONString(splitUrls));
|
|
|
+
|
|
|
+ if (UrlMatcher.matches(requestUri, splitUrls)) {
|
|
|
+ logger.debug("URI:{} Not need get user info.", requestUri);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|