diff --git a/dss-framework/dss-framework-admin-service/src/main/java/com/webank/wedatasphere/dss/framework/admin/restful/DssFrameworkAdminUserController.java b/dss-framework/dss-framework-admin-service/src/main/java/com/webank/wedatasphere/dss/framework/admin/restful/DssFrameworkAdminUserController.java index 9281ac7e4..4fe067f21 100644 --- a/dss-framework/dss-framework-admin-service/src/main/java/com/webank/wedatasphere/dss/framework/admin/restful/DssFrameworkAdminUserController.java +++ b/dss-framework/dss-framework-admin-service/src/main/java/com/webank/wedatasphere/dss/framework/admin/restful/DssFrameworkAdminUserController.java @@ -13,6 +13,8 @@ import com.webank.wedatasphere.dss.framework.admin.service.LdapService; import com.webank.wedatasphere.dss.framework.admin.xml.DssUserMapper; import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.exception.AppStandardWarnException; +import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; import org.apache.commons.codec.digest.DigestUtils; import org.apache.linkis.server.security.SecurityFilter; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +23,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,7 +93,9 @@ public Message add(@Validated @RequestBody DssAdminUser user, HttpServletRequest private Workspace getWorkspace(HttpServletRequest req) { Workspace workspace = new Workspace(); - workspace.setCookies(Arrays.stream(req.getCookies()).collect(HashMap::new, (map, cookie) -> map.put(cookie.getName(), cookie.getValue()), HashMap::putAll)); + try { + SSOHelper.addWorkspaceInfo(req, workspace); + } catch (AppStandardWarnException ignored) {} // ignore it. return workspace; } diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java index bfddf154b..659eb716d 100644 --- a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java @@ -25,6 +25,8 @@ import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.exception.AppStandardWarnException; import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; import org.apache.linkis.common.exception.ErrorException; import org.apache.linkis.server.Message; @@ -96,7 +98,11 @@ public Message getWorkspaces(HttpServletRequest request){ public Message getWorkspaceHomePage(HttpServletRequest request, @RequestParam(required = false, name = "micro_module") String moduleName) throws Exception{ //如果用户的工作空间大于两个,那么就直接返回/workspace页面 String username = SecurityFilter.getLoginUsername(request); - dssUserService.insertOrUpdateUser(username, SSOHelper.getWorkspace(request)); + Workspace workspace = new Workspace(); + try { + SSOHelper.addWorkspaceInfo(request, workspace); + } catch (AppStandardWarnException ignored) {} // ignore it. + dssUserService.insertOrUpdateUser(username, workspace); DSSWorkspaceHomePageVO dssWorkspaceHomePageVO = dssWorkspaceService.getWorkspaceHomePage(username,moduleName); return Message.ok().data("workspaceHomePage", dssWorkspaceHomePageVO); } diff --git a/dss-standard/sso-standard/sso-integration-standard/src/main/java/com/webank/wedatasphere/dss/standard/sso/utils/SSOHelper.java b/dss-standard/sso-standard/sso-integration-standard/src/main/java/com/webank/wedatasphere/dss/standard/sso/utils/SSOHelper.java index 16be44d8c..a6bbe6250 100644 --- a/dss-standard/sso-standard/sso-integration-standard/src/main/java/com/webank/wedatasphere/dss/standard/sso/utils/SSOHelper.java +++ b/dss-standard/sso-standard/sso-integration-standard/src/main/java/com/webank/wedatasphere/dss/standard/sso/utils/SSOHelper.java @@ -64,19 +64,23 @@ public static Workspace getWorkspace(Map cookies) { return workspace; } - private static void addWorkspaceInfo(HttpServletRequest request, Workspace workspace) { -// String forwardedHost = request.getHeader("X-Forwarded-Host"); -// if(StringUtils.isNotBlank(forwardedHost)) { -// workspace.setDssUrl("http://" + forwardedHost); -// } + public static void addWorkspaceInfo(HttpServletRequest request, Workspace workspace) { + String gatewayUrl = request.getHeader("GATEWAY_URL"); + if(StringUtils.isNotBlank(gatewayUrl)) { + if(gatewayUrl.startsWith("http")) { + workspace.setDssUrl(gatewayUrl); + } else { + workspace.setDssUrl("http://" + gatewayUrl); + } + } + Cookie[] cookies = request.getCookies(); + Arrays.stream(cookies).forEach(cookie -> workspace.addCookie(cookie.getName(), cookie.getValue())); if(StringUtils.isBlank(workspace.getWorkspaceName())) { throw new AppStandardWarnException(50010, "Cannot find workspace info from cookies, please ensure front-web has injected cookie['workspaceName'](不能找到工作空间名,请确认前端是否已经注入cookie['workspaceName'])."); } if(workspace.getWorkspaceId() <= 0) { throw new AppStandardWarnException(50010, "Cannot find workspace info from cookies, please ensure front-web has injected cookie['workspaceId'](不能找到工作空间名,请确认前端是否已经注入cookie['workspaceId'])."); } - Cookie[] cookies = request.getCookies(); - Arrays.stream(cookies).forEach(cookie -> workspace.addCookie(cookie.getName(), cookie.getValue())); } public static Workspace getWorkspace(HttpServletRequest request){ diff --git a/pom.xml b/pom.xml index b21eaca92..f8c284b20 100644 --- a/pom.xml +++ b/pom.xml @@ -33,11 +33,9 @@ dss-framework dss-apps/dss-apiservice-server dss-apps/dss-scriptis-server + dss-apps/dss-user-guide plugins/azkaban/linkis-jobtype plugins/linkis/dss-gateway-support - dss-data-api - dss-data-governance - dss-apps/dss-user-guide assembly plugins/dolphinscheduler