Skip to content

Commit e9c1209

Browse files
wushengyeyouyazqburde
authored andcommitted
Fix the bug that DSS cannot jump into the external system without login.
1 parent 67cecf3 commit e9c1209

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/WorkspaceRestfulApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ public Message getWorkspaceAppConns(HttpServletRequest req, @PathVariable("works
160160
String header = req.getHeader("Content-language").trim();
161161
boolean isChinese = "zh-CN".equals(header);
162162
String username = SecurityFilter.getLoginUsername(req);
163+
Workspace workspace = SSOHelper.getWorkspace(req);
163164
List<WorkspaceMenuVo> appconns;
164165
try {
165-
appconns = dssWorkspaceService.getWorkspaceAppConns(workspaceId, username, isChinese);
166+
appconns = dssWorkspaceService.getWorkspaceAppConns(workspace, workspaceId, username, isChinese);
166167
} catch (DSSErrorException e) {
167168
LOGGER.warn("{} get appconns from workspace {} failed.", username, workspaceId, e);
168169
return Message.error(e);

dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ List<DSSWorkspaceUserVO> getWorkspaceUsersByRole(int workspaceId, String roleNam
7272

7373
List<WorkspaceDepartmentVo> getWorkSpaceDepartments();
7474

75-
List<WorkspaceMenuVo> getWorkspaceAppConns(Long workspaceId, String username, boolean isChinese) throws DSSErrorException;
75+
List<WorkspaceMenuVo> getWorkspaceAppConns(Workspace workspace, Long workspaceId,
76+
String username, boolean isChinese) throws DSSErrorException;
7677

7778
DSSWorkspace getWorkspacesById(Long id, String username) throws DSSErrorException;
7879

dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceServiceImpl.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.github.pagehelper.PageHelper;
2020
import com.github.pagehelper.PageInfo;
2121
import com.webank.wedatasphere.dss.appconn.core.AppConn;
22+
import com.webank.wedatasphere.dss.appconn.core.ext.OnlySSOAppConn;
2223
import com.webank.wedatasphere.dss.appconn.manager.AppConnManager;
2324
import com.webank.wedatasphere.dss.appconn.manager.utils.AppInstanceConstants;
2425
import com.webank.wedatasphere.dss.common.exception.DSSErrorException;
@@ -44,7 +45,9 @@
4445
import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper;
4546
import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceServerConstant;
4647
import com.webank.wedatasphere.dss.standard.app.sso.Workspace;
48+
import com.webank.wedatasphere.dss.standard.app.sso.builder.SSOUrlBuilderOperation;
4749
import com.webank.wedatasphere.dss.standard.common.desc.AppInstance;
50+
import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper;
4851
import org.apache.commons.lang.ArrayUtils;
4952
import org.apache.commons.lang.StringUtils;
5053
import org.apache.linkis.common.exception.ErrorException;
@@ -546,7 +549,7 @@ public List<WorkspaceDepartmentVo> getWorkSpaceDepartments() {
546549
}
547550

548551
private List<WorkspaceMenuVo> getMenuAppInstances(List<WorkspaceMenuVo> menuVos, List<Long> userMenuAppConnIds,
549-
DSSWorkspace workspace,
552+
DSSWorkspace dssworkspace, Workspace workspace,
550553
boolean isChinese) {
551554
for (WorkspaceMenuVo menuVo : menuVos) {
552555
Long menuId = menuVo.getId();
@@ -556,11 +559,19 @@ private List<WorkspaceMenuVo> getMenuAppInstances(List<WorkspaceMenuVo> menuVos,
556559
menuAppconn.setAccessable(userMenuAppConnIds.contains(menuAppconn.getId()));
557560
AppConn appConn = AppConnManager.getAppConnManager().getAppConn(menuAppconn.getName());
558561
List<DSSApplicationBean> instanceList = new ArrayList<>();
562+
SSOUrlBuilderOperation operation;
563+
if(appConn instanceof OnlySSOAppConn) {
564+
operation = ((OnlySSOAppConn) appConn).getOrCreateSSOStandard().getSSOBuilderService().createSSOUrlBuilderOperation();
565+
SSOHelper.setSSOUrlBuilderOperation(operation, workspace);
566+
operation.setAppName(appConn.getAppDesc().getAppName());
567+
} else {
568+
operation = null;
569+
}
559570
appConn.getAppDesc().getAppInstances().forEach(appInstance -> {
560571
String label = String.join(",", appInstance.getLabels().stream()
561572
.map(l -> ((EnvDSSLabel) l).getEnv()).toArray(String[]::new));
562573
String selectedName = getAppInstanceTitle(appConn, appInstance, isChinese);
563-
String homepageUri = AppInstanceConstants.getHomepageUrl(appInstance, (long) workspace.getId(), workspace.getName());
574+
String homepageUri = AppInstanceConstants.getHomepageUrl(appInstance, operation, (long) dssworkspace.getId(), dssworkspace.getName());
564575
instanceList.add(new DSSApplicationBean(selectedName, appInstance.getBaseUrl(),
565576
homepageUri, label));
566577
});
@@ -580,12 +591,12 @@ protected String getAppInstanceTitle(AppConn appConn, AppInstance appInstance, b
580591
}
581592

582593
@Override
583-
public List<WorkspaceMenuVo> getWorkspaceAppConns(Long workspaceId, String username,
594+
public List<WorkspaceMenuVo> getWorkspaceAppConns(Workspace workspace, Long workspaceId, String username,
584595
boolean isChinese) throws DSSErrorException {
585596
DSSWorkspace dssWorkspace = getWorkspacesById(workspaceId, username);
586597
List<WorkspaceMenuVo> appconnMenuVos = isChinese ? workspaceMapper.getAppConnMenuCn() : workspaceMapper.getAppConnMenuEn();
587598
List<Long> userMenuAppConnIds = dssWorkspaceMapper.getUserMenuAppConnId(username, workspaceId);
588-
return getMenuAppInstances(appconnMenuVos, userMenuAppConnIds, dssWorkspace, isChinese);
599+
return getMenuAppInstances(appconnMenuVos, userMenuAppConnIds, dssWorkspace, workspace, isChinese);
589600
}
590601

591602
@Override

dss-standard/dss-standard-common/src/main/java/com/webank/wedatasphere/dss/standard/common/desc/AppInstance.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public interface AppInstance {
4646
* 与 dss_appinstance 数据库表的 enhance_json 字段对应,允许用户在数据库表中传入一个 json 格式的参数列表,
4747
* 第三方应用 AppConn 的 Operation 可以直接调用该方法获取 enhance_json 里面的参数列表。<br/>
4848
* 当然,您也可以通过该 AppConn 的 appconn.properties 设置一些所需的参数。appconn.properties 文件存放在
49-
* ${APPCONN_HOME}/${APPCONN_NAME}/conf 目录下
49+
* ${APPCONN_HOME}/${APPCONN_NAME}/conf 目录下。<br/>
50+
* 目前 DSS 本身需要的参数如下:
51+
* 1. reqUri:(非必须) 如果第三方应用集成了 DSS 一级规范,当在 DSS 的顶部菜单栏点击跳转到第三方应用的首页时,需要用到
52+
* 该属性。 reqUri 用于指定一个 RESTFul 请求的 URI,该 URI 可访问第三方系统后台的某个 RESTFUL 接口(随意的 Restful 接口),
53+
* DSS 放置在第三方系统的一级规范 Jar 包会自动拦截该请求,加上用户态后自动重定向给实际的前端首页。更多请参考 DSS 一级规范。
5054
* @return 第三方 AppConn 参数列表
5155
*/
5256
Map<String, Object> getConfig();

0 commit comments

Comments
 (0)