From b116a8ab30ed4234c6637c0973c8088717256fa5 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Wed, 30 Dec 2020 18:40:00 +0800 Subject: [PATCH 01/61] the base code of user authorization --- dss-server/pom.xml | 6 + dss-user-manager/pom.xml | 71 +++++++++ .../dss/user/conf/DSSUserManagerConfig.java | 16 ++ .../user/dto/request/AuthorizationBody.java | 45 ++++++ .../dss/user/service/AbsCommand.java | 33 ++++ .../dss/user/service/Command.java | 38 +++++ .../dss/user/service/MacroCommand.java | 15 ++ .../impl/LubanAuthorizationClient.java | 37 +++++ .../user/service/impl/LubanMacroCommand.java | 142 ++++++++++++++++++ .../user/service/impl/WorkspaceCommand.java | 72 +++++++++ .../dss/user/service/impl/YarnCommand.java | 21 +++ .../src/main/resources/default/HdfsPath.sh | 6 + .../src/main/resources/default/LinuxPath.sh | 7 + .../service/impl/WorkspaceCommandTest.java | 21 +++ .../dss/user/conf/DSSUserManagerConfig.class | Bin 0 -> 860 bytes .../user/dto/request/AuthorizationBody.class | Bin 0 -> 1309 bytes .../dss/user/service/AbsCommand.class | Bin 0 -> 1341 bytes .../dss/user/service/Command.class | Bin 0 -> 388 bytes .../dss/user/service/MacroCommand.class | Bin 0 -> 278 bytes .../impl/LubanAuthorizationClient.class | Bin 0 -> 750 bytes .../service/impl/LubanMacroCommand$1.class | Bin 0 -> 293 bytes .../LubanMacroCommand$SMRetryListener.class | Bin 0 -> 1952 bytes .../user/service/impl/LubanMacroCommand.class | Bin 0 -> 6262 bytes .../user/service/impl/WorkspaceCommand.class | Bin 0 -> 3322 bytes .../dss/user/service/impl/YarnCommand.class | Bin 0 -> 704 bytes .../target/classes/default/HdfsPath.sh | 6 + .../target/classes/default/LinuxPath.sh | 7 + .../service/impl/WorkspaceCommandTest.class | Bin 0 -> 1307 bytes pom.xml | 1 + 29 files changed, 544 insertions(+) create mode 100644 dss-user-manager/pom.xml create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/MacroCommand.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/YarnCommand.java create mode 100644 dss-user-manager/src/main/resources/default/HdfsPath.sh create mode 100644 dss-user-manager/src/main/resources/default/LinuxPath.sh create mode 100644 dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/AbsCommand.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/Command.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/MacroCommand.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand$1.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand$SMRetryListener.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/YarnCommand.class create mode 100644 dss-user-manager/target/classes/default/HdfsPath.sh create mode 100644 dss-user-manager/target/classes/default/LinuxPath.sh create mode 100644 dss-user-manager/target/test-classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.class diff --git a/dss-server/pom.xml b/dss-server/pom.xml index c3ec0ed388..e15a3a7f61 100644 --- a/dss-server/pom.xml +++ b/dss-server/pom.xml @@ -147,6 +147,12 @@ dss-scheduler-appjoint-core 0.9.0 + + com.webank.wedatasphere.dss + dss-user-manager + 0.9.0 + compile + diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml new file mode 100644 index 0000000000..cbc8d70604 --- /dev/null +++ b/dss-user-manager/pom.xml @@ -0,0 +1,71 @@ + + + + dss + com.webank.wedatasphere.dss + 0.9.0 + + 4.0.0 + + dss-user-manager + jar + + + + com.webank.wedatasphere.linkis + linkis-module + ${linkis.version} + provided + + + scala-xml_2.11 + org.scala-lang.modules + + + guava + com.google.guava + + + + + com.github.rholder + guava-retrying + 2.0.0 + provided + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + src/main/java + + **/*.xml + + + + + + \ No newline at end of file diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java new file mode 100644 index 0000000000..43b611a056 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java @@ -0,0 +1,16 @@ +package com.webank.wedatasphpere.dss.user.conf; + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; +import com.webank.wedatasphere.linkis.common.conf.CommonVars$; + +/** + * @program: dss-appjoint-auth + * @description: 用户模块配置文件 + * @author: luxl@chinatelecom.cn + * @create: 2020-12-30 16:26 + **/ + + +public class DSSUserManagerConfig { + public final static CommonVars LOCAL_USER_ROOT_PATH = CommonVars$.MODULE$.apply("wds.linkis.workspace.filesystem.localuserrootpath","hdfs:///dss_workspace"); +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java new file mode 100644 index 0000000000..74b76d63d4 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java @@ -0,0 +1,45 @@ +package com.webank.wedatasphpere.dss.user.dto.request; + + +import java.util.List; + +/** + * @program: user-manager + * @description: 施工单数据结构 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-12 14:29 + **/ +public class AuthorizationBody { + + private String username; + private String password; + private List hdfsList; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + public String getDatabaseName(){ + return this.username + "_default"; + } + + public List getUserPath(){ +// hdfsList.add("") + return hdfsList; + } + + +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java new file mode 100644 index 0000000000..5a3655be4b --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java @@ -0,0 +1,33 @@ +package com.webank.wedatasphpere.dss.user.service; + + +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; + +import javax.ws.rs.core.Response; + +/** + * 各模块的授权 继承这个类 根据需要实现自己的类。 + */ +public abstract class AbsCommand implements Command { + + @Override + public String capacity(AuthorizationBody body) { + return Command.SUCCESS; + } + + @Override + public String renew(AuthorizationBody body) { + return Command.SUCCESS; + } + + @Override + public String undoAuthorization(AuthorizationBody body) { return Command.SUCCESS; } + + @Override + public String authorization(AuthorizationBody body) { return Command.SUCCESS; } + + public String toMessage(String msg) { + return this.getClass().getSimpleName() + "模块开始执行:"+ msg; + } +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java new file mode 100644 index 0000000000..71413ed23b --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java @@ -0,0 +1,38 @@ +package com.webank.wedatasphpere.dss.user.service; + + +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; + +import javax.ws.rs.core.Response; + +public interface Command { + + final public static String SUCCESS = "success"; + /** + * 授权开通服务 + * @param body + * @return 成功 success 其他失败 + */ + public String authorization(AuthorizationBody body); + + /** + * 关闭授权 + * @param body + * @return 成功 success 其他失败 + */ + public String undoAuthorization(AuthorizationBody body); + + /** + * 扩容 + * @param body + * @return 成功 success 其他失败 + */ + public String capacity(AuthorizationBody body); + + /** + * 续费 + * @param body + * @return 成功 success 其他失败 + */ + public String renew(AuthorizationBody body); +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/MacroCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/MacroCommand.java new file mode 100644 index 0000000000..2bfb78cf90 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/MacroCommand.java @@ -0,0 +1,15 @@ +package com.webank.wedatasphpere.dss.user.service; + + +/** + * @program: luban-authorization + * @description: 开通命令接口 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-10 14:24 + **/ +public interface MacroCommand extends Command { + + public void add(AbsCommand command); + + +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java new file mode 100644 index 0000000000..7cc9b00b14 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java @@ -0,0 +1,37 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +//import cn.ctyun.lubanauthorization.dto.request.AuthorizationBody; +//import entity.LinkisUserDo; + +/** + * @program: luban-authorization + * @description: + * @author: luxl@chinatelecom.cn + * @create: 2020-08-10 14:24 + **/ +public class LubanAuthorizationClient { + + private LubanMacroCommand lubanCommand = new LubanMacroCommand(); + + public LubanAuthorizationClient(){ + lubanCommand.add(new YarnCommand()); +// lubanCommand.add(new LDAPCommand()); + } + +// public String authorization(AuthorizationBody json, LinkisUserDo userInfo) { +// return lubanCommand.authorization(json, userInfo); +// } +// +// public String undoAuthorization(AuthorizationBody json, LinkisUserDo userInfo) { +// return lubanCommand.undoAuthorization(json, userInfo); +// } +// +// public String renew(AuthorizationBody json, LinkisUserDo userInfo) { +// return lubanCommand.renew(json, userInfo); +// } +// +// public String capacity(AuthorizationBody json, LinkisUserDo userInfo) { +// return lubanCommand.capacity(json, userInfo); +// } +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.java new file mode 100644 index 0000000000..246cf9286f --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.java @@ -0,0 +1,142 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +import com.github.rholder.retry.*; +import com.google.common.base.Predicates; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.AbsCommand; +import com.webank.wedatasphpere.dss.user.service.Command; +import com.webank.wedatasphpere.dss.user.service.MacroCommand; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +/** + * @program: luban-authorization + * @description: 开通命令实现 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-10 14:24 + **/ +public class LubanMacroCommand implements MacroCommand { + + private List commandList = new ArrayList<>(); + + private static Integer RETRY_COUNT = 1; + + @Override + public void add(AbsCommand command) { + + commandList.add(command); + } + + @Override + public String authorization(AuthorizationBody body) { + try{ + return this.execute("authorization", body); + }catch (Exception e){ + return e.getMessage(); + } + } + + @Override + public String undoAuthorization(AuthorizationBody json) { + try{ + return this.execute("undoAuthorization", json); + }catch (Exception e){ + return e.getMessage(); + } + } + + @Override + public String capacity(AuthorizationBody json) { + try{ + return this.execute("capacity", json); + }catch (Exception e){ + return e.getMessage(); + } + } + + @Override + public String renew(AuthorizationBody json) { + try{ + return this.execute("renew", json); + }catch (Exception e){ + return e.getMessage(); + } + } + + + /** + * 授权操作基础方法 + * @param funName 调用的函数名 + * @param body 传入的数据 + * @return + * @throws ClassNotFoundException + * @throws NoSuchMethodException + */ + private String execute(String funName, AuthorizationBody body) { + + for (AbsCommand command : commandList) { + Callable callable = () -> { + switch (funName){ + case "authorization": + return command.authorization(body); + + case "undoAuthorization": + return command.undoAuthorization(body); + + case "capacity": + return command.capacity(body); + } + return command.authorization(body); + }; + + Retryer retryer = RetryerBuilder.newBuilder() + .retryIfResult(Predicates.not(Predicates.equalTo(Command.SUCCESS))) + .retryIfExceptionOfType(IOException.class) + .retryIfRuntimeException() + .withStopStrategy(StopStrategies.stopAfterAttempt(RETRY_COUNT)) + .withRetryListener(new SMRetryListener()) + .build(); + + try { + retryer.call(callable); + } catch (ExecutionException e) { + return e.getMessage(); + } catch (RetryException e) {//需要通知到我们处理为什么开通失败 + return command.toMessage(e.getNumberOfFailedAttempts()+"重试失败"); + } catch (Exception e){ + return e.getMessage(); + } + } + return "success"; + } + + /** + * 重试监听器 + * @param + */ + private class SMRetryListener implements RetryListener { + + @Override + public void onRetry(Attempt attempt) { +// logger.info("[retry]time=" + attempt.getAttemptNumber()); + if (attempt.hasException()) { +// logger.error("retry exception", attempt.getExceptionCause()); + } + if (attempt.hasResult()) { + if (attempt.getResult() == null) { +// logger.info("retry return data is null"); + } else { +// logger.info("retry return data is:{}", attempt.getResult()); + } + } + } + + } + + +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java new file mode 100644 index 0000000000..c9e4d33ea6 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java @@ -0,0 +1,72 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + +import com.webank.wedatasphpere.dss.user.conf.DSSUserManagerConfig; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.AbsCommand; +import com.webank.wedatasphpere.dss.user.service.Command; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +/** + * @program: luban-authorization + * @description: 创建用户空间 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-13 13:39 + **/ + +public class WorkspaceCommand extends AbsCommand { + + @Override + public String authorization(AuthorizationBody body) { + String rootPath = "hdfs://"; +// DSSUserManagerConfig.LOCAL_USER_ROOT_PATH.getValue(); + String bashCommand; + BufferedReader br = null; + BufferedWriter wr = null; + try { + if(rootPath.indexOf("hdfs:") == -1){ + bashCommand = this.getClass().getClassLoader().getResource("./default/LinuxPath.sh").getPath(); + }else { + bashCommand = this.getClass().getClassLoader().getResource("default/LinuxPath.sh").getPath(); + } + + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec("sudo sh " + bashCommand + " " + body.getUsername() + " " + "/Users/test22"); + + br = new BufferedReader(new InputStreamReader(process.getInputStream())); + wr = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); + + String inline; + while ((inline = br.readLine()) != null) { + if (!inline.equals("")) { + inline = inline.replaceAll("<", "<").replaceAll(">", ">"); + + System.out.println(inline); + } else { + System.out.println("\n"); + } + } + br.close(); + br = new BufferedReader(new InputStreamReader(process.getErrorStream())); //错误信息 + while ((inline = br.readLine()) != null) { + if (!inline.equals("")) + System.out.println( inline ); + else + System.out.println("\n"); + } + + int status = process.waitFor(); + if (status != 0){ + return "restart go server error"; + } + return Command.SUCCESS; + } + catch (Exception e){ + e.printStackTrace(); + return e.getMessage(); + } + } +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/YarnCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/YarnCommand.java new file mode 100644 index 0000000000..daf870f69c --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/YarnCommand.java @@ -0,0 +1,21 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.AbsCommand; +import com.webank.wedatasphpere.dss.user.service.Command; + +/** + * @program: luban-authorization + * @description: 开通yarn权限的实现 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-10 14:24 + **/ +public class YarnCommand extends AbsCommand { + + @Override + public String authorization(AuthorizationBody body) { + + return Command.SUCCESS; + } +} diff --git a/dss-user-manager/src/main/resources/default/HdfsPath.sh b/dss-user-manager/src/main/resources/default/HdfsPath.sh new file mode 100644 index 0000000000..dffe821128 --- /dev/null +++ b/dss-user-manager/src/main/resources/default/HdfsPath.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +user=$1 +dic=$2 +hdfs dfs -mkdir $dic +hdfs dfs -chown $user:$user \ No newline at end of file diff --git a/dss-user-manager/src/main/resources/default/LinuxPath.sh b/dss-user-manager/src/main/resources/default/LinuxPath.sh new file mode 100644 index 0000000000..21d9a2b858 --- /dev/null +++ b/dss-user-manager/src/main/resources/default/LinuxPath.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +user=$1 +dic=$2 +echo $1 $2; +sudo mkdir $dic +#sudo chown $user:$user $dic \ No newline at end of file diff --git a/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java new file mode 100644 index 0000000000..a61ae1de43 --- /dev/null +++ b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java @@ -0,0 +1,21 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; + +class WorkspaceCommandTest { + + @Test + @MethodSource("body") + void authorization() { + AuthorizationBody body = new AuthorizationBody(); + body.setUsername("luxl"); + body.setPassword("123321"); + WorkspaceCommand test = new WorkspaceCommand(); + test.authorization(body); + System.out.println("当前测试方法结束"); + } +} \ No newline at end of file diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..f455774d0371cda16e35d0ce153743b3a0b67c34 GIT binary patch literal 860 zcmbVK%Wl&^6g`udonVp@TA;jNLM;nhNC*%vNL5#o+Q&aw&ih%`dNSk z5(_?nk3!r@P|G4x5u3T^p1F@R_s-8>-+usjiU$pt*r?+Qu9~=JVzWW;dL0IC7`SQR z7Q?#dcXqvgFW5iqANqc`|9-domf^VLk{A zeZXHfve?YRHZU25GVnxO8knt}h>yZ{h1awXb)dZFGy2{UVR-5X4sBb`aadEKHZao- zjkI!Y_E2E%P&GZFqkwK&O?=)Oy?L8bGF!@1dfPy%Tsbn3e&IWmT&O8e?nUjo3|@=6 z8-w``;U0-V@ww+r>y`=)?9>{5+dh?b;k~ED5n6NkBE=F62)TnY+@gBHr8G28=Rb<6i9nVw0bzj|WVsKrL$EAo=_k@}&q-Ah<_wwHESWP* mCec=h&`N!QS8#`}NeY}xCRc`%SuB2??jzqNhE+P5xc3*tiUP|3 literal 0 HcmV?d00001 diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/AbsCommand.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/AbsCommand.class new file mode 100644 index 0000000000000000000000000000000000000000..b69a1e4a3145b3be1eafebe8d5ea15b98f563d91 GIT binary patch literal 1341 zcmbtT&rcIU6#j;mZmGpW5fH^9{=gQ56-7N@On}5w#YB|E<8*h@4t96z?kogPUX9*O zOgwPHqh3m)#6Q6Q1LDp9!1$(YXh9M-@i6n|$NRqb=6i2`{`vL;z#Q&okj1!xD`{Lc za4mx*#`V$l3?^_xZ;NS^w4F3CW#A@5>Vb5nddQF{mR1>(OP(zla%Jg?<d8ni!;6gYT2o zl!<)e3z<%6Ukf^Pa2-L(5knXz5X1R6B!j1rjKm=sIfdjx9FoyfNG@VD(&Q;US!+`G qj^v9S(zS_H6Gjv1d=E`iG@8g9muswpzi=p50hdr{$u-uJ_wrvEF)zFT literal 0 HcmV?d00001 diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/Command.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/Command.class new file mode 100644 index 0000000000000000000000000000000000000000..8375cab0d3e494ac83ec7a4f17faf869542b6fde GIT binary patch literal 388 zcmaiw%}xSA5QM97`4K_En{S{OCnnxF=|)c^9yWMyW;?LB%;5Y$@X0Sn6%vpX=% z$L{;{d;yqaAkY)&3xoupwI(dbJC&#MVIt11ZfUOA7MH@5MrvziZA~ei?y)j*9obEu zrkv^3OL*jAUZe+0!(g!B~D-)GO6Muj| z$~Z;1=>g4VXJ@{hot>F)K0aUH0c@kDBZrEHB^?SXIm}{N!-|e9Dk-w6VNJt2gW)C? z_gjJIao=G$Zrg!p-V4I+=x}(t-uisg|_s?MdDc^yylimNU0sz-0kpCruGS`~}C{)o1_! literal 0 HcmV?d00001 diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand$1.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand$1.class new file mode 100644 index 0000000000000000000000000000000000000000..c6013f56f7bd8efe08d03b13dd202643d746b442 GIT binary patch literal 293 zcmbu4!D<3Q42J(y+tpR*o_g-VvxDFRh*F`Tc<>40Y|z!&nPq0zzFQA{fId_)o_jRm z&qpB1Pk#Tte*nxe%8+Fk67qfMqLp>!gz&cM4(zvVV_1c{W?xRvd}YGxhqo@I${)AV zoqyx2%Y)Tj7`o7m zM$^;^Eix@~-Ldm_qrt6ej=U`ymfFMaylOQn!r9~%lQhEx zTjyq(JBF0o%7{#ctV_iW;W>K+!}WwE90v8JMQh&Vt}Do3qvzlzk3mrG$f@se@Pc)idPL@{T zfxs}~2l(F~80OD3Iw7iolE?M!B5$@E6e}4ui+e4HI#^!%H;Ki<7T@8T$*r2UUfB}5 zms>tNkuJz|S;0KR!8shi-n%yE*EzIH(-qpKSz9>|mke*uEL?XjPj6nwq|iZ%m+Y3K zi#0<|S+Z-$XJngHs2ETYN5AAAC|FSO5RX(mmgEVZDp+KA-Rp&Ne8?CQ#}5g^v_v`a z>~>^E7hKQbPz%E;IXdH~Vzvj2Zk#%IS9f*M^bFhb|9is_BV{nQ#MgxPhaX9$yIaQa ztk;M!PA@McL84Kz0p24)RQ35d zhA=|X1Sk6$F-Xa-^zTe)+A6WnZ literal 0 HcmV?d00001 diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanMacroCommand.class new file mode 100644 index 0000000000000000000000000000000000000000..da777b3b2944ca2cdc1a9af3cbfbaab6650c8b31 GIT binary patch literal 6262 zcmcIo33wFc8GdK8$!sQL2rGm}Zj6uw!V-=YNQx#AByA3w1SpnjC%co)!0yg6I}1d6 z*h@>RmLA&DVoxnC)*1wt0Ij8`)oM?BU-q!Y-nFGqZ+-un&1OTA%@QB;Jo&Hr=DWZ5 z|7IWk|LKPStj0eS)WepMRN#SKj5XL>f_>QULz}|QfQ%ay_;8~SJw9ynVY_(xni9Mg zuM@-TW!&T^qnj1ng15>z;KSP#ydAfS;Wlx2yNq{;`JfoyDFnPr!MpJu1$W?1arRyr z?^7@zhs5UnV)%f9!?;Vv2NhJ}Mj0QH@nHo^U@KURkBHSrefXG|?-s*73d->NkBZ@5F?>o$yHCcaW!x`gP{uI{YHKW}TP+bSk>9#e{W+ZH#4Vc--M2jn`VFTHgbZzYE+HrkL=hluM375KzBU&sRXpPx= zShq-1)M&&EdxM06s_JbLye(#kN=$1rVtPk1+N)bVT5p6W{x&nHMYd^{A@=D*uibCZ z;^vD`(TK)rc9Pb#YeCB#R+sX%P)NeMs*B*2Wva1+};qG;9hlw3xa3=u&;Z9!%QQ zHe8jZZrYCLt>L)7Ngq1(5j11Lq(x=yz(z+Cx+vRM)s6~b!|qS^2CRNF5@I!2qWS_( z4QA8Qyhy}N=J~EI7m8>}6EFy}!$cJCqDe$JRV4Q%V;x%5sS~HVohr+OyL@!<48(^E zXjN`S8prxv)U})56I-oYC(N+!C*AYWrJl14J6+e}(PeUl+@t9%UBEEfS%(S&AV;s_KsS(fHtwu%Nc z$~dWFGlo>W0y~E3oS+9BpoDe1odu$Wi5xSk#=V|=M#kRqVG8FW z8TNy?J^HmohrXXtVpm1J-k7r)%`q)k!SC@0(H#GgbmEGVa5P)J{O{Tq5O{Okl#`U2 zZlw!~-epUX*({~+CW~B}m=0a&keX&Vq6fH)nz2Byme2!REInidHCy!EGFvb$(qpnT zvi&z4URPQU78FwuGa0i@ZqpaeMVnSW7YW-hr-^9o>(Ud+2pPBM&v?R)CgV@4Tb|~h zfwRuO9`+Uz8nYeXe3-Be&EMOzhV@RyY$K{?*t2^a!J+gg1aDp=W^dCXNy=rmx8?%h zZrhAApBb;PAwpJ`;6YO#3#!Ss^=O;AN`blCZQ|sbVcTVH#;6_vEmNz=55*_;XTGP53c4Ye$4`A z!HWuPp@_6zweKnb-Je9B$gG#|nDrFa=R zNurNTbL^*f1*9#l@fR&U33;%6SqjC2dmQHTz7 zI+98=l1i}!FDH*KzF7omvy5);*tm|Bs!T35K&dMzscurKTgQ>gPI;` zw%)t6!n^D=rUUB>hv4_m7{bgUl&3Ju|DqHsQn>5^%uZp>5ay;Z?+oVesF6-$K?(~~ zShT*VqNt)Uh0C`e!OHb=g`C0_gPgr*u!K2YB@U`nsPQjNfk{=H!gBGLr^SOup0)im z2AMxQ5ki>1oQm1xFQ#I?otk@{tn0v~w4n?0m_OCfupGUNNsv_+qL*}LR3EnU{hipw zlRaGRhJgqJ zxRcSp4%hR^JnVO>$18lA$@9Z_HMJ78a@fgu5A}2F&gBuz@CcEIsD?Et`Y#k2`md^`ag{UH4f2@_6y=U?J+S$SdIQt(Cfa#3 zohSfF00#AToW=!LE+C1O01S`gB0qfp!!r6sDlILUTUhuna*UJOOGgVp+LM9S1&-?h zpLYnWk7KrgLdi)Sf)3ZSDbM2UVd&R!zKr{|oKfcEZ}@8%To3+&zu~V0-Z$`A0Ph<~ K^Cr9*Z+Q-b5ey^% literal 0 HcmV?d00001 diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class new file mode 100644 index 0000000000000000000000000000000000000000..be21aa0bb01534a97da77b75cbd5f89e716c3a98 GIT binary patch literal 3322 zcma)8TX-C08GiqCvoo1Y6WBDR+m?1qOPcgFq(H2j(vqgFRMP`V4+ce;-JN8o-Q8K{ z(53}NQSbmL;t7f%Dq0c5g0Mj%6;P|<{@6-AyBApJ)I1=llNe z{m$P%@BZhF3jl7yUoxahy<4(4b3+ zqI{NAI2y{hM};fjJ$cAi5GXjQ;S{DcEX8RJ-8iG*UIq6_;%7Ciz~?k9$NiG?c@YyASh-m_pq5Mkdhd2vS#6^>Dux=BF6l@ z?FkHxWSydM%F39f6MW=M-}K7)vgKMv&hw1Gvs{D!lXliJ>|(iK9CO?gUfIlA!%nei zmU4pvi_O5#JFb1k^lhgkaHMwupgG?$TUuVZl71;K{INS)peYJjId{(8ip=&02eHSts3d zbGt=GSjWv6VC3?-2`_CJ012c{Zzf#o%rgMmMbQ)TL?U|Pz*E|*{HcthICSu%s)(EjbLqn?64sN+ps z;5&Od)-&l3D)_CAxA3-tcXa#?zb8x6@dpg(xG0VKBmTrVx%AX@{nR95!dA81l;ye( z3wD^m!+Tz)cHB7|M9FCN4nnhqju)Rdv^@ z(?#IwIw=|#O|)o4un+7~&YC(n!FK6w7zxpk>f6@@elT;~%K9wWNy{HDnBm;%ZJcc( zk^S6R*B+hgsELd?vgcW(R|-~H6z`rRUXy7j$f)IoJuYzFd~eeA}~a@i{71UCO~6B=fH)abNEIw0G*WXhSY`c5rf zF>A`o3atM>c=gFH`90&~zDqR+V&SA(qwyVyHX0fDp61%bIB}9~EVl;Ay zo~%POapu5Bqg+x|&ZC^X)p;%P#xx7OmYRyMT4sZNcW|J)R=L32d8kkj*fvje=Be2$ zNlisOcG~l;BEK@6fTbMWgY@eVujOc1(ygwrZkoyAeak}yeiSqrT}_1*A#n*l%DrAafHVgACa@j1aHVj|OK62gQh%alzevYKx^+`x zQ3bJDhIyQslB(4aFE2nYoG*+csld%d`kEhj(xH+jN zQWdN@ixhX)CDvB3E^&RLhmW-S3f3oST<^Kdf8#dM7j7>~;SG(tHr902Vb{*WcGN-s zSqJ%tv~klwTX)-&jKSvf3FEwUwSs=RY(38`w272hha1Eiu~t5@2r}?4R&rg&w-rpn zO0;1Wy098O%-{glF$LFS0_$-vdhr-G;wfz6N5f`JGn4P2AAe<*|IYmWi>Kdbk}hGJ zP>>c0+#-_LAy#3hSc4&I92Py;EjD6LnB+4|^IB@%ft_3j@o(IUAzCnj3)qEW@B;#m zU^lrcaoQ=hm$nVyy{ZJU+VL^mMhTWfR4Q_}4>Bl}>M7`yST5Pecy{fry2jO=i+a9$3p0D-EYR zSH9#boK5+iFwsDVp@@PmLq#Ou)YVx=R7+tvp2f>?7S9}{U~-e2cm>fpKCcJIYp z@TrK#d>9)QjcHHLqY^{^-_sdNL!B63Ua3@?+S+qY(!FIA;4qwSuF6Ub2FE78FD;3B zzB&7^rVO3U$$ihRw&Msn`XK4afPMxXvPFtGAtTHmzk|Ik%3EX$i{uVUHX*d`C; mSFl4iC7%&y2($IB!(VLv4Csks&s%Ou^8Sm5z82 z+BxCP^PEMVWLD+5wa7ggjrW|fU`6^2_p*6q8|xy+oi#Eh54i8HxWW^L>H9|L3(ugx zAoIeIwrd$n%3JeYo)^=~wz*@@3qP1-XyRe8qCEMW2U0miCa25|hN)w~n}ISs@iZhL zW9n~|y97bdv4Ccd2UV3RL3KY0oj}@RQTmdkm~tEylnIj(Jz3=~8>=BnO06pcs+_yh z*eh`4kZG5D-1ZIEQw3>K_>3S8%sCZ$c|qCg3fu}w|3t-eUq+kJeVBm5tGvK|;?8bjCax6R#`uS=g_ z{d&Judh@09Y3t|CX6fxa4cB$th%!zeT}{=Dk@^g+kv@jSon_-;ZdK&T)#!_0ftEVl zCRIDr+5M2Yz?07MWOOH@s9Em&>&i137SjKH90&f*bAaC5h93xDr1%? z1w>46n@&c1ne0I~gXTs-mV-Vt)5{QjHT2V|09|708DtsRy1{L*59R50YU|6+26Rwg zuLPhICujuPuQmdS7QY}{OE$BEn#bFy&1RCZBI+{9`XaO)#L3q%Gn6SJvGfs*Nxg`s z{S>{>XlXM&MJ?2}QmQue5NrzV^fGmnQ}plugins/azkaban/linkis-jobtype plugins/linkis/linkis-appjoint-entrance assembly + dss-user-manager From 8a1bc0bfe4960d94de09f852c2089273e9993ab2 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Mon, 4 Jan 2021 10:18:17 +0800 Subject: [PATCH 02/61] the code of unit test --- .gitignore | 4 +++- dss-user-manager/pom.xml | 5 +++++ .../dss/user/conf/DSSUserManagerConfig.java | 5 ++++- .../user/service/impl/WorkspaceCommand.java | 4 ++-- .../src/main/resources/linkis.properties | 18 ++++++++++++++++++ .../service/impl/WorkspaceCommandTest.java | 5 ++++- .../dss/user/conf/DSSUserManagerConfig.class | Bin 860 -> 759 bytes .../user/service/impl/WorkspaceCommand.class | Bin 3322 -> 3419 bytes .../target/classes/linkis.properties | 18 ++++++++++++++++++ .../service/impl/WorkspaceCommandTest.class | Bin 1307 -> 1236 bytes 10 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 dss-user-manager/src/main/resources/linkis.properties create mode 100644 dss-user-manager/target/classes/linkis.properties diff --git a/.gitignore b/.gitignore index ece2343af4..55103199ba 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ plugins/azkaban/linkis-jobtype/target/ plugins/linkis/linkis-appjoint-entrance/target/ sendemail-appjoint/sendemail-core/target/ -visualis-appjoint/appjoint/target/ \ No newline at end of file +visualis-appjoint/appjoint/target/ + +logs \ No newline at end of file diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml index cbc8d70604..f877a21766 100644 --- a/dss-user-manager/pom.xml +++ b/dss-user-manager/pom.xml @@ -29,6 +29,11 @@ + + com.webank.wedatasphere.linkis + linkis-common + 0.9.4 + com.github.rholder guava-retrying diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java index 43b611a056..7b2fde8b7d 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java @@ -3,6 +3,8 @@ import com.webank.wedatasphere.linkis.common.conf.CommonVars; import com.webank.wedatasphere.linkis.common.conf.CommonVars$; +import java.util.ResourceBundle; + /** * @program: dss-appjoint-auth * @description: 用户模块配置文件 @@ -12,5 +14,6 @@ public class DSSUserManagerConfig { - public final static CommonVars LOCAL_USER_ROOT_PATH = CommonVars$.MODULE$.apply("wds.linkis.workspace.filesystem.localuserrootpath","hdfs:///dss_workspace"); + private final static ResourceBundle resource = ResourceBundle.getBundle("linkis"); + public final static String LOCAL_USER_ROOT_PATH = resource.getString("wds.dss.user.root.dir"); } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java index c9e4d33ea6..b75566d96e 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java @@ -21,8 +21,8 @@ public class WorkspaceCommand extends AbsCommand { @Override public String authorization(AuthorizationBody body) { - String rootPath = "hdfs://"; -// DSSUserManagerConfig.LOCAL_USER_ROOT_PATH.getValue(); + String rootPath = DSSUserManagerConfig.LOCAL_USER_ROOT_PATH; + System.out.println(rootPath); String bashCommand; BufferedReader br = null; BufferedWriter wr = null; diff --git a/dss-user-manager/src/main/resources/linkis.properties b/dss-user-manager/src/main/resources/linkis.properties new file mode 100644 index 0000000000..d1ac907e5a --- /dev/null +++ b/dss-user-manager/src/main/resources/linkis.properties @@ -0,0 +1,18 @@ +# +# Copyright 2019 WeBank +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +wds.dss.user.root.dir=file:///appcom/tmp/wds/scheduler diff --git a/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java index a61ae1de43..b12c23aa35 100644 --- a/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java +++ b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.java @@ -1,6 +1,7 @@ package com.webank.wedatasphpere.dss.user.service.impl; +import com.webank.wedatasphpere.dss.user.conf.DSSUserManagerConfig; import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.provider.MethodSource; @@ -9,7 +10,7 @@ class WorkspaceCommandTest { @Test - @MethodSource("body") +// @MethodSource("body") void authorization() { AuthorizationBody body = new AuthorizationBody(); body.setUsername("luxl"); @@ -17,5 +18,7 @@ void authorization() { WorkspaceCommand test = new WorkspaceCommand(); test.authorization(body); System.out.println("当前测试方法结束"); + +// DSSUserManagerConfig.LOCAL_USER_ROOT_PATH.getValue(); } } \ No newline at end of file diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.class index f455774d0371cda16e35d0ce153743b3a0b67c34..c75fa0415cc7684698ea835e92683f5c9e7d911f 100644 GIT binary patch literal 759 zcmbtS%Wl&^6g@Xh6UP|ZniQJyEcD63?t)zlQVAdyhM+j@Hk#PebXwQ0#y0&fS_u#f zK7fxx+;Jj=1Z9I4Gjoscxvz7-|M>b1z*B74Xkp1h$Hp@5v|!<`g?q-hZ;S^`JZxfx zU}>3WrH&+FIXD&{gkKga@%vNsMVZEl+#$4sUUx4T?uW1X!+x(f7{1>dydk&~P9oB= z9~N4rWA<(As#F!v2{W5p2ZVYzi#hyUpi=p+JRM0r5Tk?O+0e&7^@C!Tq7)=$GOLeJ(JkeSyp(l(hk*{HyIxcqh|4!DUnTNW07k+(U#`Py#n i3uZ1+zd+rc{e;FPnkE*(#Ih@|1!lU8++w7L+dl!Y>AP?M literal 860 zcmbVK%Wl&^6g`udonVp@TA;jNLM;nhNC*%vNL5#o+Q&aw&ih%`dNSk z5(_?nk3!r@P|G4x5u3T^p1F@R_s-8>-+usjiU$pt*r?+Qu9~=JVzWW;dL0IC7`SQR z7Q?#dcXqvgFW5iqANqc`|9-domf^VHc@mO!v9i&pD~H ze@{*Wm-D?Puqnh1Yz}cFT^3vDHo3{7hhB?5`Yi?+G#RqEnXMMvxW#1HVmmtwZncQ8 z$z(*Iqb5m<+t_JxyS8`fpgRn98{BDe7k67MT!S`V3TG-5y`9S z9PJw!txEQdCRePmImv|0M@+gA|EjrTHdB0TQ^P3@({87~w&gURXya22pV@q_Ww7~z zFGczag}-Q9vd(6Puf(p`_CT^usAY48l{Q~%#j||l{^s9deycs-Nu!$sf2lfmOQ4{- zXZvt}RdYv&?yIePxO<>)q)A*u1B$HH_NK&w4#e6r@$U2b>p2={JhQ?Bp1h7D@o*<)b0$;g@UpaCG%A)~~V8&sx%RCGZGaB-+ zJi_b7nK$dQ|8Dsky#;kG%67Hn5TJ`fX94~Y{!^lL1K!9iBwFK zV`*~IEOPu)#!`3c9Ip(bWV3p|z`AWzuxXrV_@v^ZKKhhs|b zF;ki!KmUW!Xz2wyqm#>Ki)q>TY^{s31zLC6f4Y(XReqgSaTDRfRHiCX=t1<)>E7!BIJ^QKF!VXi%jo8l`NLs-#(6##&ZO+1)Z!acQKU2EitN=Smt0 zO0j9K65Egk*-NuLHAN^aSyvO1=szxIh*p?uXps#0`#98zre@c29Ws@whU+CagNTZg b(@LAXrF;d}(JmviUSfN&&Qs~`vj_hHC8G5t delta 1098 zcmYk5TW}Ob6o$XvThDgdh!a`a1ViE`o0t$5C<$?*K?LuDzF1{S5fu`GqGC4QKwa;6 zK}E-Ff{ND|)M!9wk!V!Zs8~Gct1nhr7Uhc%`eIR*czTh-shYq4bNZbBKQ+_+Q|+N_ zY5zZar-0M=-UwXbaizy9!&R&{T+KCxYgyy5*3d`4VI2b=>kZd&y=H^Kx{e#%dZWip zhK=0pG3er=D;m<=qPf*@8@C%W++mo>Ce3Eeoi2HoSxp^x8)_-Jt$RG~b>8=R-0$&# zqYrvKsh_VazIQZDI*U88?o#YddK0}enZy4&fe9Dx>JuY51 z)UEl<@;P5<_F2BxZuj#Z*JBM%hHvBcQ(fiJ2_RHX_l7H>4(FbGU&eZzwPbs&iR~?OoL?Pr ze22XL41xBD6CC#iB5EQ|4D=*3dnd{CW<~R)GP6o$vO!{!TFKT`va`#aT&6xqW)l%} zdIN8oMOn{ph-e(9LD(sNE~3eA_Vcm?-Y#0QGF|KF;U9$hr&j2+Yi|3$S-Y53ypGA{ zM6C9RZuK#hUyiDTQB`v(tr}Dl^HrnDxs^Cwa&rcmEjUY}I#R;Z)KkM8@-)&(6Wuh^ zPYauAWgG2`FjtOG2W1NEV*v-`+Wjd1`Jhz)!D9ZVOKAe-bEeADqv~0r8d<8EN-R@( zmaBHo;dHUwBqt&#wmmEn?B+MlVyTSK&lG2~3^{>pWx4EnB2*<^=gM%M{C=cEw5m9d y^QA-nIDsh0BkTe$L=ji>xJY_qq{Q)JR**@MR;{e$5;-Q9O6?lVVe;XhcHmzWKHjGQ diff --git a/dss-user-manager/target/classes/linkis.properties b/dss-user-manager/target/classes/linkis.properties new file mode 100644 index 0000000000..d1ac907e5a --- /dev/null +++ b/dss-user-manager/target/classes/linkis.properties @@ -0,0 +1,18 @@ +# +# Copyright 2019 WeBank +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +wds.dss.user.root.dir=file:///appcom/tmp/wds/scheduler diff --git a/dss-user-manager/target/test-classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.class b/dss-user-manager/target/test-classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommandTest.class index a6ec5f1de5690dfccdf0f956c07890bd3c25cd90..a6c30434eed8810384348ae79cd3102d3f47e091 100644 GIT binary patch delta 201 zcmWlTJ5Iwu07T!eEw8(cH)XPUPV_HQQJK3{6$UIubtcUr=8d-d$UN3~UTmN;E fI7`Y28Rwib<&46$in0Ci>nuQ!yU&6Pmy+2(Ha!`v delta 256 zcmWlUyH0~p0EWLqYPp28wsz1&yx`rc6sVVK;%FD09G%b-#k7S`XyQXSv6%Q08l4<` z0B4`acv$}1^!>m3tI_}Y`}zjDoEp@zRn`m?Y>oBOH#9a&-%{B&(6CF{(b=V~v1hQ) zfr_KjdGE)f*SU<-d*?A9N14(LnaAFnfpx*KwZSg=d19X)w&g z;!`{|Ts%S5^?cuRO? Date: Tue, 5 Jan 2021 19:28:43 +0800 Subject: [PATCH 03/61] Workspace path modification initialization --- .../dss/application/conf/ApplicationConf.java | 17 ++++++++ .../dss/application/entity/DSSUser.java | 9 ++++ .../dss/application/entity/WorkSpacePath.java | 41 +++++++++++++++++++ .../restful/ApplicationRestfulApi.java | 36 ++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java index 5eca714b6e..984b15ea94 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java @@ -26,4 +26,21 @@ public class ApplicationConf { public static final CommonVars FAQ = CommonVars.apply("wds.linkis.application.dws.params",""); + + public static final String SUPER_USER_NAME = CommonVars.apply("wds.linkis.super.user.name","").getValue(); + public static final String WORKSPACE_USER_ROOT_PATH = CommonVars.apply("wds.linkis.workspace.user.root.path","").getValue(); + public static final String HDFS_USER_ROOT_PATH = CommonVars.apply("wds.linkis.hdfs.user.root.path","").getValue(); + public static final String RESULT_SET_ROOT_PATH = CommonVars.apply("wds.linkis.result.set.root.path","").getValue(); + public static final String WDS_SCHEDULER_PATH = CommonVars.apply("wds.linkis.scheduler.path","").getValue(); + + + + + + + + + + + } diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java index 43323288a4..655257aea2 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java @@ -25,6 +25,15 @@ public class DSSUser { private String username; private String name; private Boolean isFirstLogin; + //增加是否超级用户表示 0-不是超级用户 1-是超级用户 + private int isSuperUser = 0; + + public int getIsSuperUser() { + return isSuperUser; + } + public void setIsSuperUser(int isSuperUser) { + this.isSuperUser = isSuperUser; + } public Long getId() { return id; diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java new file mode 100644 index 0000000000..1507532b3f --- /dev/null +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java @@ -0,0 +1,41 @@ +package com.webank.wedatasphere.dss.application.entity; + +public class WorkSpacePath { + private String WorkspaceRootPath; + private String HdfsRootPath; + + public String getWorkspaceRootPath() { + return WorkspaceRootPath; + } + + public void setWorkspaceRootPath(String workspaceRootPath) { + WorkspaceRootPath = workspaceRootPath; + } + + public String getHdfsRootPath() { + return HdfsRootPath; + } + + public void setHdfsRootPath(String hdfsRootPath) { + HdfsRootPath = hdfsRootPath; + } + + public String getResultRootPath() { + return ResultRootPath; + } + + public void setResultRootPath(String resultRootPath) { + ResultRootPath = resultRootPath; + } + + public String getSchedulerPath() { + return SchedulerPath; + } + + public void setSchedulerPath(String schedulerPath) { + SchedulerPath = schedulerPath; + } + + private String ResultRootPath; + private String SchedulerPath; +} diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java index 2842487a1c..f4c35d03f6 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java @@ -17,9 +17,11 @@ package com.webank.wedatasphere.dss.application.restful; +import com.webank.wedatasphere.dss.application.conf.ApplicationConf; import com.webank.wedatasphere.dss.application.entity.Application; import com.webank.wedatasphere.dss.application.entity.DSSUser; import com.webank.wedatasphere.dss.application.entity.DSSUserVO; +import com.webank.wedatasphere.dss.application.entity.WorkSpacePath; import com.webank.wedatasphere.dss.application.handler.ApplicationHandlerChain; import com.webank.wedatasphere.dss.application.service.ApplicationService; import com.webank.wedatasphere.dss.application.service.DSSApplicationUserService; @@ -70,7 +72,41 @@ public Response getBaseInfo(@Context HttpServletRequest req){ } DSSUser dssUser = dataworkisUserService.getUserByName(username); DSSUserVO dataworkisUserVO = new DSSUserVO(); + String superUserName = ApplicationConf.SUPER_USER_NAME; + //是否超级用户登录 + if(username.equals(superUserName)){ + dssUser.setIsSuperUser(1); + }else{ + dssUser.setIsSuperUser(0); + } + dataworkisUserVO.setBasic(dssUser); return Message.messageToResponse(Message.ok().data("applications",applicationList).data("userInfo",dataworkisUserVO)); } + + + @GET + @Path("getWorkSpace") + public Response getWorkSpace(@Context HttpServletRequest req){ + + String username = SecurityFilter.getLoginUsername(req); + applicationHandlerChain.handle(username); + List applicationList = applicationService.listApplications(); + for (Application application : applicationList) { + String redirectUrl = application.getRedirectUrl(); + if(redirectUrl != null) { + application.setHomepageUrl(ApplicationUtils.redirectUrlFormat(redirectUrl,application.getHomepageUrl())); + application.setProjectUrl(ApplicationUtils.redirectUrlFormat(redirectUrl,application.getProjectUrl())); + } + } + + WorkSpacePath workSpacePath = new WorkSpacePath(); + workSpacePath.setHdfsRootPath(ApplicationConf.HDFS_USER_ROOT_PATH); + workSpacePath.setResultRootPath(ApplicationConf.RESULT_SET_ROOT_PATH); + workSpacePath.setSchedulerPath(ApplicationConf.WDS_SCHEDULER_PATH); + workSpacePath.setWorkspaceRootPath(ApplicationConf.WORKSPACE_USER_ROOT_PATH); + + return Message.messageToResponse(Message.ok().data("applications",applicationList).data("workSpacePath",workSpacePath)); + + } } From f573189d3a84a2fb1f885765e0656b34c3552ab7 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Mon, 4 Jan 2021 19:25:55 +0800 Subject: [PATCH 04/61] Improve the basic code, add front-end code local debugging through --- .gitignore | 1 + dss-application/pom.xml | 6 ++ dss-server/pom.xml | 12 ++- .../dss/server/restful/UserManagerApi.java | 58 +++++++++++ dss-server/src/main/resources/application.yml | 2 +- .../user/dto/request/AuthorizationBody.java | 16 +-- .../impl/LubanAuthorizationClient.java | 24 +---- .../user/service/impl/WorkspaceCommand.java | 33 +++--- .../src/main/resources/default/LinuxPath.sh | 4 +- .../user/dto/request/AuthorizationBody.class | Bin 1309 -> 1505 bytes .../impl/LubanAuthorizationClient.class | Bin 750 -> 0 bytes .../user/service/impl/WorkspaceCommand.class | Bin 3419 -> 0 bytes .../target/classes/default/LinuxPath.sh | 4 +- web/src/commonData/i18n/common/en.json | 14 +++ web/src/commonData/i18n/common/zh.json | 14 +++ web/src/js/service/router.js | 9 ++ web/src/js/view/userManager/index.vue | 98 ++++++++++++++++++ 17 files changed, 252 insertions(+), 43 deletions(-) create mode 100644 dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java delete mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class delete mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class create mode 100644 web/src/js/view/userManager/index.vue diff --git a/.gitignore b/.gitignore index 55103199ba..3e275cd751 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ plugins/linkis/linkis-appjoint-entrance/target/ sendemail-appjoint/sendemail-core/target/ visualis-appjoint/appjoint/target/ +dss-user-manager/target/ logs \ No newline at end of file diff --git a/dss-application/pom.xml b/dss-application/pom.xml index 54583b1239..e2b32c0793 100644 --- a/dss-application/pom.xml +++ b/dss-application/pom.xml @@ -47,6 +47,12 @@ dss-appjoint-loader ${dss.version} + + org.apache.htrace + htrace-core + 3.2.0-incubating + compile + diff --git a/dss-server/pom.xml b/dss-server/pom.xml index e15a3a7f61..3b891b457b 100644 --- a/dss-server/pom.xml +++ b/dss-server/pom.xml @@ -93,6 +93,10 @@ gson com.google.code.gson + + jsr311-api + javax.ws.rs + @@ -152,7 +156,13 @@ dss-user-manager 0.9.0 compile - + + + com.github.rholder + guava-retrying + 2.0.0 + provided + diff --git a/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java new file mode 100644 index 0000000000..cb9f7687fb --- /dev/null +++ b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java @@ -0,0 +1,58 @@ +package com.webank.wedatasphere.dss.server.restful; + +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.impl.LubanAuthorizationClient; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +/** + * @program: luban-authorization + * @description: 鲁班对外交互的接口 包括施工 注册用户 + * @author: luxl@chinatelecom.cn + * @create: 2020-08-12 14:24 + **/ + +@Component +@Path("/dss") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class UserManagerApi { + + private ExecutorService executor = Executors.newCachedThreadPool(); + private LubanAuthorizationClient client = new LubanAuthorizationClient(); + + @POST + @Path("/user") + public Response createUser(@Context HttpServletRequest req, AuthorizationBody body) { + + final Future futureRate = executor.submit(new Callable() { + public String call() { + //以异步处理 + return client.authorization(body); + } + }); + + return Message.messageToResponse(Message.ok()); + } + + + @GET + @Path("/paths") + public Response getPaths(@Context HttpServletRequest req) { + List paths = new ArrayList<>(); + paths.add("hdfs:///dss_workspace/linkis"); + return Message.messageToResponse(Message.ok().data("paths", paths)); + } +} diff --git a/dss-server/src/main/resources/application.yml b/dss-server/src/main/resources/application.yml index 419506c3f8..a745a45074 100644 --- a/dss-server/src/main/resources/application.yml +++ b/dss-server/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: eureka: client: serviceUrl: - defaultZone: http://127.0.0.1:20303/eureka/ + defaultZone: http://127.0.0.1:8080/eureka/ instance: metadata-map: test: wedatasphere diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java index 74b76d63d4..a442b1e656 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java @@ -13,7 +13,16 @@ public class AuthorizationBody { private String username; private String password; - private List hdfsList; + + public List getPaths() { + return paths; + } + + public void setPaths(List paths) { + this.paths = paths; + } + + private List paths; public String getUsername() { return username; @@ -31,15 +40,10 @@ public void setPassword(String password) { this.password = password; } - public String getDatabaseName(){ return this.username + "_default"; } - public List getUserPath(){ -// hdfsList.add("") - return hdfsList; - } } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java index 7cc9b00b14..1d9c864256 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java @@ -1,8 +1,7 @@ package com.webank.wedatasphpere.dss.user.service.impl; -//import cn.ctyun.lubanauthorization.dto.request.AuthorizationBody; -//import entity.LinkisUserDo; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; /** * @program: luban-authorization @@ -15,23 +14,10 @@ public class LubanAuthorizationClient { private LubanMacroCommand lubanCommand = new LubanMacroCommand(); public LubanAuthorizationClient(){ - lubanCommand.add(new YarnCommand()); -// lubanCommand.add(new LDAPCommand()); + lubanCommand.add(new WorkspaceCommand()); } -// public String authorization(AuthorizationBody json, LinkisUserDo userInfo) { -// return lubanCommand.authorization(json, userInfo); -// } -// -// public String undoAuthorization(AuthorizationBody json, LinkisUserDo userInfo) { -// return lubanCommand.undoAuthorization(json, userInfo); -// } -// -// public String renew(AuthorizationBody json, LinkisUserDo userInfo) { -// return lubanCommand.renew(json, userInfo); -// } -// -// public String capacity(AuthorizationBody json, LinkisUserDo userInfo) { -// return lubanCommand.capacity(json, userInfo); -// } + public String authorization(AuthorizationBody body) { + return lubanCommand.authorization(body); + } } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java index b75566d96e..39f78b6a07 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java @@ -1,14 +1,12 @@ package com.webank.wedatasphpere.dss.user.service.impl; -import com.webank.wedatasphpere.dss.user.conf.DSSUserManagerConfig; import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import com.webank.wedatasphpere.dss.user.service.AbsCommand; import com.webank.wedatasphpere.dss.user.service.Command; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; +import java.util.List; /** * @program: luban-authorization @@ -21,23 +19,34 @@ public class WorkspaceCommand extends AbsCommand { @Override public String authorization(AuthorizationBody body) { - String rootPath = DSSUserManagerConfig.LOCAL_USER_ROOT_PATH; - System.out.println(rootPath); + List paths = body.getPaths(); + + + for(Integer i=0; id)wQqUM+1Ur4O$@wJ0J;NDM16kS0cQQIsY`ZzW>j8=5or1tyhL zB_u{hM#g4-MC@}b!az>4*4ig)@4fbo`O&rb`uX?_pnwGvT}XLgBCQ~!AnV4I2^}c~ zIRkmc({9YTG22+oy7V*4KB_fN-#o@)+1^xzd||80M(w*|@F$AL)`gX;+m&jrSgF}d z$r3}Lc)Dj*OV)YC+O3wiF3-waN-#_&8jUfYEXfsiB{iNFz37u!KH)E5j=|X3FCSR- zs_n%*;_`&QFhl0WI^(h~;>;&wn*X|=&fy4yVHhK%2C3d8=ESa4`X2m_lt6&cbbbSL zRgfO&&v7AyA*#p^+E0@rq`kzQA0MgCmMEzh;)H5Tj+jY93$ZXI85E-!lT9%oH?)2| zN;_imT||Q8fBn>_r&`eDtrnIU%@h-zu4_%j5xN~Dr-R~s>L&C8ozX0M}O-KL$ delta 357 zcmX|5u};EJ6g}^?rKK$@G}w}YAQlu56?I`TnCRx<;^1U36ft3vI+*wkCU|ED|3DMP zsELz{P8z?!(VsBBHpJZI+?#XHIrn}WS9ME90EDxLYxYp}*2Rp}uVA%hlA9iLMM}Dw3@K1KzL65dsiw=2>F1hEdpuwOW zbo_4nv>%vQg==CGQ}o7PnMxPZ7Gv}!6`4iXa=M;H4h(7W*ao;LAXcs2gWrmYV_Kjd zu{IPq)RJw(L_#@hdYk@CpVqg+z*LRScNjft_Y0C#+0QzS8wXg@>Ve}GcG v10NxlQU#2lQAWuoY&ggW4Z|#o^eI`X_|5+-vB+K#2d!i>V&??oMN{bye7HC^ diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class deleted file mode 100644 index 748970fd6d83884e624c48b3cf34ce42b1c99fa0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 750 zcmbtSOHaZ;5dO9lE42tB_=dzAaIhCIK4Mf7jS1>OL*jAUZe+0!(g!B~D-)GO6Muj| z$~Z;1=>g4VXJ@{hot>F)K0aUH0c@kDBZrEHB^?SXIm}{N!-|e9Dk-w6VNJt2gW)C? z_gjJIao=G$Zrg!p-V4I+=x}(t-uisg|_s?MdDc^yylimNU0sz-0kpCruGS`~}C{)o1_! diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.class deleted file mode 100644 index d411f05b86b77c5ade6a635e4516e4cd9061f0d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3419 zcma)8YjjlA75+|`%)Pm}Br+kuAWD2eLPD;fAWjer0V?f;qPG<5JVN$~svMOv1M{!I;4tW)h z1{Vbd_iAXtT`D~J^;HBKLL66dLawLfrjrUzDY#F={rIGYHTaZ<)%di6&nWn;Bz{iA zRd_(dIy@*j52<)qs(wVpqbeSg)5leOUd0nCz92VzQ3`!Y4qsOB6$M{a@ihfs*Ki}g zA%|}&_?Chv1)@7`#}0N0EbHt#BoG;JGnPPW(srzaVLoMfV`eHxN-XK7&D-Mn$aN}0|velliY`h{%4@+>3c`$p(np26R7J8cXP+_y+jRuSJC^{O30%Xo?hP$JF#7A|_qdspeO<|;=5f==na-3k z8hExdMLo?a)6Z7a%2O?}Me#x>u=6~0TOE6(OeBO-@Z7ZJ^WgRT;WCl@sO{wFK2H3= z3_|V`2lykQy$)~RblNJ&vr;0GqPt^Kyl zllFzN?Uf$Zu?^c5d`HK3v0K42I-bRI3cjb~`}l!CV>UDCCy1@%dAy+DjE*1TM+$zd z<0p7gU{$Y?u_nzh7Z^;;a9WW-*e3y9@#JzFziCp@ds?z@keRITlf?G;_+mr7j#U~2fV13 z*I{{{OTTPc`purZREi&_EBB-3@40l>@n@<0FVfoGOGjU{ZV24GbcFttKWE|+6u<99 z6S$&wv~q0`SWzQYip4xyr9cSueXz}G*O@f-j*iN_8#Enr%JK$CvZt8h$)SP%Lb08UH9a)>9y?g+>RdCFI%=h9ggRvf139x)Gdt_+a*0T5T5G}#otBwbmr zc%?2EEVC%yzCgSx(@c;N%P-X@fom5#Qu&mQ6&T|qNkZu*sLGnhB|^EJuAHZTuAyjB zMYUnH&)ZXL8Bw!Pu$+v*=Jz(Cu1{6U60MO3kV)W}vLC5|TTQlzHEpE@HhutJtt&}? z))gaO`l_u=jXDOEuBm`7V94mV)mW82BB`y!uCGuMq7r3d)N_a)uR+Y?EP$`HAxTwP zJu~t}!j{TzZ|2xi=cQ*k&HB3TWHa)tLXIzs{#;IA$0FWYB&#ncu_dK*u1|&1ZTn;` zq~lq`nGh#TJJ>I4BVSC+_SQoATCr7*c~ndjC^E?R0dFm?!A*QP%D)B(*6HmWZ{f<| zm(?1Ln`R(hDY18OjFyNiaVzI~c>@yY<4RyBZsSPdhVy8IM$)b4&@gxo%X*54hy?!| zdt!}6L>r#Ps!c^GMX0f+BD5l!51v6=m84fluVZ;48jsGRWnu=cu`7yLv6;VEj6-)3 zZF0VnLlNyotV$@eSUoX|H4||H$7is123IB`vsg#sRVCupGgv=^jznWTQp7bA3H2hj z#nsrgMO^n3Iyk#Nc0&;xVjE+f{3KMG9#?7mnM;4;G}cv`UX;R{>UDKjb=6?6n}cns zfxKM<`G>TzXM0n7(`iIwo6p9Kv+}4#Y>~s(vy8?H(J6Xxqv#Ud@{47V0XWWQHu(OI zAdY5S$>;extiaWrtw%4TxeM2005`zFMm&H{Jc({TVS4ZqHnSfaY^PiBcSii5jP<`6 z?f>8w5y1}8iiB8;+XNBB2J9AH=%>~J(Tly}ChRK({1ijpO*?jBH^%|IgWJ*1lyGnX zd$?BkXnF#B$yJHdOsV~7;_iQyC5Y9G58)0;M1& diff --git a/dss-user-manager/target/classes/default/LinuxPath.sh b/dss-user-manager/target/classes/default/LinuxPath.sh index 21d9a2b858..26fc03de5e 100644 --- a/dss-user-manager/target/classes/default/LinuxPath.sh +++ b/dss-user-manager/target/classes/default/LinuxPath.sh @@ -3,5 +3,5 @@ user=$1 dic=$2 echo $1 $2; -sudo mkdir $dic -#sudo chown $user:$user $dic \ No newline at end of file +sudo mkdir -p $dic +sudo chown $user:$user $dic \ No newline at end of file diff --git a/web/src/commonData/i18n/common/en.json b/web/src/commonData/i18n/common/en.json index 0bb80defb2..f0e29bbba5 100644 --- a/web/src/commonData/i18n/common/en.json +++ b/web/src/commonData/i18n/common/en.json @@ -1662,6 +1662,20 @@ "success": { "update": "Successfully updated global variables!" } + }, + "userManager": { + "createUser": "create user", + "username" : "username", + "password": "password", + "rootPath": "Root Path", + "spacePath": "Space root Path", + "hdfsPath": "HDFS root Path", + "resultPath": "Result root Path", + "schedulerPath": "Scheduler root Path", + "usernameNotNull": "username cannot be empty", + "passwordNotNull": "password cannot be empty", + "createSuccess": "create user Success", + "createFail": "create user Fail" } } } \ No newline at end of file diff --git a/web/src/commonData/i18n/common/zh.json b/web/src/commonData/i18n/common/zh.json index 3bd655377a..5a17a2a350 100644 --- a/web/src/commonData/i18n/common/zh.json +++ b/web/src/commonData/i18n/common/zh.json @@ -1662,6 +1662,20 @@ "success": { "update": "全局变量更新成功!" } + }, + "userManager": { + "createUser": "创建用户", + "username" : "账号", + "password": "密码", + "rootPath": "用户根目录", + "spacePath": "工作空间目录", + "hdfsPath": "HDFS根目录", + "resultPath": "结果存储根目录", + "schedulerPath": "调度存储根目录", + "usernameNotNull": "用户名不能为空", + "passwordNotNull": "密码不能为空", + "createSuccess": "创建账号成功", + "createFail": "创建账号失败" } } } \ No newline at end of file diff --git a/web/src/js/service/router.js b/web/src/js/service/router.js index 15456a21ea..954b6dff6a 100644 --- a/web/src/js/service/router.js +++ b/web/src/js/service/router.js @@ -101,6 +101,15 @@ const router = new VueRouter({ }, component: () => import('../view/commonIframe/index.vue'), }, + { + name: 'USER MANAGER', + path: 'userManager', + component: () => import('../view/userManager/index.vue'), + meta: { + title: 'userManager', + publicPage: true, + }, + }, { path: 'console', name: 'Console', diff --git a/web/src/js/view/userManager/index.vue b/web/src/js/view/userManager/index.vue new file mode 100644 index 0000000000..0b657d3374 --- /dev/null +++ b/web/src/js/view/userManager/index.vue @@ -0,0 +1,98 @@ + + + + + From a1aaa7800c171726ff853998d188af333dd93caf Mon Sep 17 00:00:00 2001 From: hantang Date: Thu, 7 Jan 2021 14:41:52 +0800 Subject: [PATCH 05/61] Workspace path modification initialization --- .../dss/application/entity/WorkSpacePath.java | 31 +++++++++------- .../restful/ApplicationRestfulApi.java | 20 +++-------- .../application/util/ApplicationUtils.java | 36 +++++++++++++++++-- 3 files changed, 58 insertions(+), 29 deletions(-) diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java index 1507532b3f..9e8b0003f2 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java @@ -1,41 +1,48 @@ package com.webank.wedatasphere.dss.application.entity; public class WorkSpacePath { - private String WorkspaceRootPath; - private String HdfsRootPath; + private String workspaceRootPath; + private String hdfsRootPath; + private String resultRootPath; + private String schedulerPath; public String getWorkspaceRootPath() { - return WorkspaceRootPath; + return workspaceRootPath; } public void setWorkspaceRootPath(String workspaceRootPath) { - WorkspaceRootPath = workspaceRootPath; + this.workspaceRootPath = workspaceRootPath; } public String getHdfsRootPath() { - return HdfsRootPath; + return hdfsRootPath; } public void setHdfsRootPath(String hdfsRootPath) { - HdfsRootPath = hdfsRootPath; + this.hdfsRootPath = hdfsRootPath; } public String getResultRootPath() { - return ResultRootPath; + return resultRootPath; } public void setResultRootPath(String resultRootPath) { - ResultRootPath = resultRootPath; + this.resultRootPath = resultRootPath; } public String getSchedulerPath() { - return SchedulerPath; + return schedulerPath; } public void setSchedulerPath(String schedulerPath) { - SchedulerPath = schedulerPath; + this.schedulerPath = schedulerPath; } - private String ResultRootPath; - private String SchedulerPath; + + + + + + + } diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java index f4c35d03f6..8601a71b8b 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java @@ -39,6 +39,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; /** @@ -87,26 +89,14 @@ public Response getBaseInfo(@Context HttpServletRequest req){ @GET @Path("getWorkSpace") - public Response getWorkSpace(@Context HttpServletRequest req){ - - String username = SecurityFilter.getLoginUsername(req); - applicationHandlerChain.handle(username); - List applicationList = applicationService.listApplications(); - for (Application application : applicationList) { - String redirectUrl = application.getRedirectUrl(); - if(redirectUrl != null) { - application.setHomepageUrl(ApplicationUtils.redirectUrlFormat(redirectUrl,application.getHomepageUrl())); - application.setProjectUrl(ApplicationUtils.redirectUrlFormat(redirectUrl,application.getProjectUrl())); - } - } - + public Response getWorkSpace(@Context HttpServletRequest req) throws Exception { WorkSpacePath workSpacePath = new WorkSpacePath(); workSpacePath.setHdfsRootPath(ApplicationConf.HDFS_USER_ROOT_PATH); workSpacePath.setResultRootPath(ApplicationConf.RESULT_SET_ROOT_PATH); workSpacePath.setSchedulerPath(ApplicationConf.WDS_SCHEDULER_PATH); workSpacePath.setWorkspaceRootPath(ApplicationConf.WORKSPACE_USER_ROOT_PATH); - - return Message.messageToResponse(Message.ok().data("applications",applicationList).data("workSpacePath",workSpacePath)); + ArrayList> responses = ApplicationUtils.convertToMap(workSpacePath); + return Message.messageToResponse(Message.ok().data("paths",responses)); } } diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/util/ApplicationUtils.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/util/ApplicationUtils.java index 4f0fabd1b9..af65bd3227 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/util/ApplicationUtils.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/util/ApplicationUtils.java @@ -17,12 +17,16 @@ package com.webank.wedatasphere.dss.application.util; +import com.webank.wedatasphere.dss.application.entity.WorkSpacePath; import com.webank.wedatasphere.dss.common.exception.DSSErrorException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; /** * Created by chaogefeng on 2019/11/20. @@ -46,8 +50,36 @@ public static String redirectUrlFormat(String redirectUrl,String url){ return String.format(REDIRECT_FORMAT,redirectUrl,URLEndoder(url)); } - public static void main(String[] args) throws DSSErrorException { - System.out.println(redirectUrlFormat("http://127.0..0.1:8090/qualitis/api/v1/redirect","http://127.0..0.1:8090/#/projects/list?id={projectId}&flow=true")); + + public static ArrayList> convertToMap(Object obj) + throws Exception { + + ArrayList> mapList = new ArrayList(); + Field[] fields = obj.getClass().getDeclaredFields(); + for (int i = 0, len = fields.length; i < len; i++) { + String varName = fields[i].getName(); + boolean accessFlag = fields[i].isAccessible(); + fields[i].setAccessible(true); + HashMap map = new HashMap<>(); + Object o = fields[i].get(obj); + if (o != null){ + map.put("key",varName); + map.put("value",o.toString()); + mapList.add(map); + } + + fields[i].setAccessible(accessFlag); + } + + return mapList; + } + + public static void main(String[] args) throws Exception { +// System.out.println(redirectUrlFormat("http://127.0..0.1:8090/qualitis/api/v1/redirect","http://127.0..0.1:8090/#/projects/list?id={projectId}&flow=true")); + + WorkSpacePath workSpacePath = new WorkSpacePath(); + workSpacePath.setWorkspaceRootPath("/"); + System.out.println(convertToMap(workSpacePath)); } } From 55163767a3c68687437fbc377f1f40e7af29f910 Mon Sep 17 00:00:00 2001 From: hantang Date: Thu, 7 Jan 2021 17:09:05 +0800 Subject: [PATCH 06/61] User management path authorization changes --- .gitignore | 9 ++++++- .../user/dto/request/AuthorizationBody.java | 8 +++--- .../user/service/impl/WorkspaceCommand.java | 24 ++++++++++++------ .../user/dto/request/AuthorizationBody.class | Bin 1505 -> 1622 bytes 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 3e275cd751..f765b77e7c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,11 @@ sendemail-appjoint/sendemail-core/target/ visualis-appjoint/appjoint/target/ dss-user-manager/target/ -logs \ No newline at end of file +logs +### Example user template template +### Example user template + +# IntelliJ project files + +out +gen diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java index a442b1e656..87a0b5dcd0 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/dto/request/AuthorizationBody.java @@ -1,6 +1,7 @@ package com.webank.wedatasphpere.dss.user.dto.request; +import java.util.HashMap; import java.util.List; /** @@ -14,15 +15,16 @@ public class AuthorizationBody { private String username; private String password; - public List getPaths() { + + public List> getPaths() { return paths; } - public void setPaths(List paths) { + public void setPaths(List> paths) { this.paths = paths; } - private List paths; + private List> paths; public String getUsername() { return username; diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java index 39f78b6a07..43f4e94608 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java @@ -6,7 +6,9 @@ import java.io.BufferedReader; import java.io.InputStreamReader; +import java.util.HashMap; import java.util.List; +import java.util.Set; /** * @program: luban-authorization @@ -19,15 +21,21 @@ public class WorkspaceCommand extends AbsCommand { @Override public String authorization(AuthorizationBody body) { - List paths = body.getPaths(); - - - for(Integer i=0; i> paths = body.getPaths(); + for(HashMap map : paths){ + String path = map.get("value"); + String rst = createDir(path, body); + if(rst != Command.SUCCESS){ + return rst; + } } + +// for(Integer i=0; iAFQfP5gN$PGr6rj;`W}hJ8NP`HHa=O2Wr_MZiFxVz!6ikRdFj@ZFEWZu z+^~k(S3{Fn<&zs3?HK(gA7B(G#_-LL8Lu)j@=jjJB0BjTvpS;)kR?2slf{Ttf`OGm za#%3lVATSOYlFp`Ssi8d7{nPE7MfuuNt Q1cM}yW@OL+l1vPm05twaVE_OC delta 126 zcmcb{^N@Q&FQdw2ekQTW7EC-7udiWN)6j%*C!c4uV^p8a$0QDt+#JDlm64HW@_bg& z$<8e5j6##MSzKAg7+4v^CqHBrpL~YJlTijNtIevxssI#M1dHdh>H}?<&uYu60Tj~& NibXK$OtxZ^0RToZA8`Nx From 511282d91c782c650c46fb30a035cdd659d5fcf8 Mon Sep 17 00:00:00 2001 From: hantang Date: Fri, 8 Jan 2021 10:08:24 +0800 Subject: [PATCH 07/61] User management path authorization modification - add userPath --- .../dss/application/conf/ApplicationConf.java | 4 ++++ .../dss/application/entity/WorkSpacePath.java | 11 +++++++++++ .../application/restful/ApplicationRestfulApi.java | 3 ++- .../dss/server/restful/UserManagerApi.java | 7 ------- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java index 984b15ea94..3d14c7c378 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java @@ -32,6 +32,10 @@ public class ApplicationConf { public static final String HDFS_USER_ROOT_PATH = CommonVars.apply("wds.linkis.hdfs.user.root.path","").getValue(); public static final String RESULT_SET_ROOT_PATH = CommonVars.apply("wds.linkis.result.set.root.path","").getValue(); public static final String WDS_SCHEDULER_PATH = CommonVars.apply("wds.linkis.scheduler.path","").getValue(); + public static final String WDS_USER_PATH = CommonVars.apply("wds.linkis.user.path","user").getValue(); + + + diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java index 9e8b0003f2..4f2b258915 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/WorkSpacePath.java @@ -5,6 +5,17 @@ public class WorkSpacePath { private String hdfsRootPath; private String resultRootPath; private String schedulerPath; + private String userPath; + + public String getUserPath() { + return userPath; + } + + public void setUserPath(String userPath) { + this.userPath = userPath; + } + + public String getWorkspaceRootPath() { return workspaceRootPath; diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java index 8601a71b8b..a3e4e579bc 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java @@ -88,13 +88,14 @@ public Response getBaseInfo(@Context HttpServletRequest req){ @GET - @Path("getWorkSpace") + @Path("getPath") public Response getWorkSpace(@Context HttpServletRequest req) throws Exception { WorkSpacePath workSpacePath = new WorkSpacePath(); workSpacePath.setHdfsRootPath(ApplicationConf.HDFS_USER_ROOT_PATH); workSpacePath.setResultRootPath(ApplicationConf.RESULT_SET_ROOT_PATH); workSpacePath.setSchedulerPath(ApplicationConf.WDS_SCHEDULER_PATH); workSpacePath.setWorkspaceRootPath(ApplicationConf.WORKSPACE_USER_ROOT_PATH); + workSpacePath.setUserPath(ApplicationConf.WDS_USER_PATH); ArrayList> responses = ApplicationUtils.convertToMap(workSpacePath); return Message.messageToResponse(Message.ok().data("paths",responses)); diff --git a/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java index cb9f7687fb..dba5d4a5cb 100644 --- a/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java +++ b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/restful/UserManagerApi.java @@ -48,11 +48,4 @@ public String call() { } - @GET - @Path("/paths") - public Response getPaths(@Context HttpServletRequest req) { - List paths = new ArrayList<>(); - paths.add("hdfs:///dss_workspace/linkis"); - return Message.messageToResponse(Message.ok().data("paths", paths)); - } } From 600fa6390ad1da707c59f6d11a6eecb514f786fb Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 11 Jan 2021 15:22:17 +0800 Subject: [PATCH 08/61] The Metastore interface was added, and the Metastore service needs to be configured --- dss-user-manager/pom.xml | 5 ++ .../dss/user/service/AbsCommand.java | 3 +- .../dss/user/service/Command.java | 4 +- .../dss/user/service/common/CommonFun.java | 48 ++++++++++++++++++ .../impl/LubanAuthorizationClient.java | 1 + .../user/service/impl/MetastoreCommand.java | 39 ++++++++++++++ .../user/service/impl/WorkspaceCommand.java | 1 - .../src/main/resources/default/Metastore.sh | 28 ++++++++++ .../service/impl/MetastoreCommandTest.java | 25 +++++++++ .../dss/user/service/AbsCommand.class | Bin 1341 -> 1389 bytes .../dss/user/service/Command.class | Bin 388 -> 436 bytes .../impl/LubanAuthorizationClient.class | Bin 0 -> 1019 bytes .../target/classes/default/HdfsPath.sh | 6 --- .../target/classes/linkis.properties | 18 ------- 14 files changed, 150 insertions(+), 28 deletions(-) create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/common/CommonFun.java create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java create mode 100644 dss-user-manager/src/main/resources/default/Metastore.sh create mode 100644 dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommandTest.java create mode 100644 dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class delete mode 100644 dss-user-manager/target/classes/default/HdfsPath.sh delete mode 100644 dss-user-manager/target/classes/linkis.properties diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml index f877a21766..e7252d0527 100644 --- a/dss-user-manager/pom.xml +++ b/dss-user-manager/pom.xml @@ -46,6 +46,11 @@ RELEASE test + + com.typesafe + config + 1.3.3 + diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java index 5a3655be4b..df7d99c6d0 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java @@ -5,6 +5,7 @@ import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import javax.ws.rs.core.Response; +import java.io.IOException; /** * 各模块的授权 继承这个类 根据需要实现自己的类。 @@ -25,7 +26,7 @@ public String renew(AuthorizationBody body) { public String undoAuthorization(AuthorizationBody body) { return Command.SUCCESS; } @Override - public String authorization(AuthorizationBody body) { return Command.SUCCESS; } + public String authorization(AuthorizationBody body) throws IOException { return Command.SUCCESS; } public String toMessage(String msg) { return this.getClass().getSimpleName() + "模块开始执行:"+ msg; diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java index 71413ed23b..5fc296807a 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java @@ -3,7 +3,7 @@ import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; -import javax.ws.rs.core.Response; +import java.io.IOException; public interface Command { @@ -13,7 +13,7 @@ public interface Command { * @param body * @return 成功 success 其他失败 */ - public String authorization(AuthorizationBody body); + public String authorization(AuthorizationBody body) throws IOException; /** * 关闭授权 diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/common/CommonFun.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/common/CommonFun.java new file mode 100644 index 0000000000..b633862aaa --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/common/CommonFun.java @@ -0,0 +1,48 @@ +package com.webank.wedatasphpere.dss.user.service.common; + +import com.webank.wedatasphpere.dss.user.service.Command; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.logging.Logger; + +/** + * @author anlexander + * @date 2021/1/8 + */ +public class CommonFun { + static Logger log = Logger.getLogger("CommonFun"); + public static String process(Process process) { + BufferedReader br; br = new BufferedReader(new InputStreamReader(process.getInputStream())); + String inline; + try{ + while ((inline = br.readLine()) != null) { + if (!inline.equals("")) { + inline = inline.replaceAll("<", "<").replaceAll(">", ">"); + log.info(inline); + } else { + log.info("\n"); + } + } + br.close(); + br = new BufferedReader(new InputStreamReader(process.getErrorStream())); + while ((inline = br.readLine()) != null) { + if (!inline.equals("")) { + log.info(inline); + } else { + log.info("\n"); + } + + } + if (process.waitFor() != 0) { + log.info("restart go server error:" + process.waitFor()); + } + + }catch (Exception e){ + e.printStackTrace(); + return e.getMessage(); + } + return Command.SUCCESS; + + } +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java index 1d9c864256..9ebe720a6b 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java @@ -15,6 +15,7 @@ public class LubanAuthorizationClient { public LubanAuthorizationClient(){ lubanCommand.add(new WorkspaceCommand()); + lubanCommand.add(new MetastoreCommand()); } public String authorization(AuthorizationBody body) { diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java new file mode 100644 index 0000000000..9de692c1f1 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java @@ -0,0 +1,39 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + +import com.typesafe.config.Config; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.AbsCommand; +import com.webank.wedatasphpere.dss.user.service.Command; +import com.webank.wedatasphpere.dss.user.service.common.CommonFun; +import com.typesafe.config.ConfigFactory; +import java.io.IOException; + +/** + * @author anlexander + * @date 2021/1/5 + */ +public class MetastoreCommand extends AbsCommand { + + @Override + public String authorization(AuthorizationBody body) throws IOException { + Config parms = ConfigFactory.load("config/properties.conf"); + String rst = createDb(body,parms); + return rst != Command.SUCCESS ? rst : Command.SUCCESS; + } + + private String createDb(AuthorizationBody body, Config parms) throws IOException { + + String bashCommand; + String userName = body.getUsername(); + String res = null; + if (userName != null) { + String dbName = userName + parms.getString("db_tail"); + String path = parms.getString("base_path") + dbName + ".db"; + bashCommand = this.getClass().getClassLoader().getResource(parms.getString("metastore_sh")).getPath(); + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec("sudo sh " + bashCommand + " " + userName + " " + dbName + "" + path); + res = CommonFun.process(process); + } + return res; + } +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java index 43f4e94608..e25c685879 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/WorkspaceCommand.java @@ -8,7 +8,6 @@ import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; -import java.util.Set; /** * @program: luban-authorization diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh new file mode 100644 index 0000000000..644796c9e9 --- /dev/null +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +user_name = $1 +db_name = $2 +path = $3 + +#一、kerberos认证 +kinit -kt /etc/security/keytabs/${user_name}.keytab ${user_name}/nm-bigdata-030066029.ctc.local@EWS.BIGDATA.CHINATELECOM.CN.UAT + +#二、metastore操作 +hive -e "create database is not exists $db_name" +if [[ $? -ne 0 ]]; then + echo "create database failed" +else + #修改数据库所属,需要hive metastore开启赋权功能,并将hdfs用户添加到admin中 + hive -e "set role admin ; grant all on database $db_name to user $user_name" +fi + +#三、hdfs操作 +if [[ $? -ne 0 ]]; then + #修改hdfs路径所属 + hdfs dfs -chown $user_name:$user_name $path + #修改hdfs路径权限 + hdfs dfs -chmod -R 700 $user_name +else + #回滚 + hive -e "drop database $db_name" +fi \ No newline at end of file diff --git a/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommandTest.java b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommandTest.java new file mode 100644 index 0000000000..3f930f47ab --- /dev/null +++ b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommandTest.java @@ -0,0 +1,25 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +class MetastoreCommandTest { + + @Test +// @MethodSource("body") + void authorization() { + AuthorizationBody body = new AuthorizationBody(); + body.setUsername("anlexander"); + body.setPassword("123321"); + MetastoreCommand test = new MetastoreCommand(); + try { + test.authorization(body); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("当前测试方法结束"); + } +} \ No newline at end of file diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/AbsCommand.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/AbsCommand.class index b69a1e4a3145b3be1eafebe8d5ea15b98f563d91..9a13844d6a40bf5c47a4a2bb8fce8bacb3ffabb4 100644 GIT binary patch delta 244 zcmdnX^_I)()W2Q(7#J8#7%aFLco>w~8B{nJRM{ESxENR%ltDu3Tnrivnjo$g2ZJ_< z)?sJRWoOXaXcfuG$K_g)oLW$lnV(n8&Y(YeBI7v$0|rBO1|uE@V+Io*22%#J$@xrD z%;pRxlY5waM1->v%M$f7^YuOb;W{T@W4gx3J9#a$6{Fx}T^9Mt>@2E`VnCJ)qZEkG zD#akmz%)6KMS)Qk$d~1p20EC9fssK5h-De%Cf{VSRaamT1d56=Fab$91|bGvAPr*4 QGbjL6F)}Cuc}xsS052ga9smFU delta 192 zcmWlTO%B0O6ot=yt-N|^#7{_6sZ#2Q!^_tm9PLYV;i<0-pk27 z=R0R~zv`~?=kN9akYS_XB9!Pk=u1QjHbOHE6o!aR9XS}AoJdS1X4m{ce4$r)jznVN zVu{qn3Tr+I&&rVUS?u{IKIHP-%BjpHdq;Kc0UzxFH4Tx+i5-z|*lNM&VqqHxsOXm( T5ZXJaqNdYOTOVl!x(RguJ2f0R diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/Command.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/Command.class index 8375cab0d3e494ac83ec7a4f17faf869542b6fde..63eaee3bb5843a853c0c90b1d7a0a6e7bb16f1a1 100644 GIT binary patch delta 120 zcmZo+-oh+!>ff$?3=9k=3?l3d0_+Te69o(zg(f;>@o~9UB&QaXWaj4;voi=!Ts1|E zkwG{su`E$PGhg4+A1*uDj!{{ck%1Fv2nz!v0~ZS;12+Q)ki*Ep1EqOEG*FHYNHQ_- F0|4|l7CHa` delta 72 zcmdnO+`=qy>ff$?3=9k=41(+oeC!PT69o(z1tvOWP24kSatfoeG6M@E11AFq1Bm8= R(%c}Lfsug+NHQ_-0su7<3Y`D| diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class new file mode 100644 index 0000000000000000000000000000000000000000..1675ae5c39d0cb10391bf4bd38b9e4dba61677cd GIT binary patch literal 1019 zcmbtTO>fgc5Pj>oF)?nN7Fr;XLV-gQBz)n5!dDszgk<2*62x(BubORbZ&caZWG2lchQ>y3%wUgHEEpC8nTeN08VbG5!-SaSKt((mb1h3;leU@2 zoZzBUB1L8>pLzZ_&G35T1mdw#z83EaksJS*?52u840^#X-{*e9 zvmJlSXqoNMId(`}48t?4Gq_u-(2;m5%Q|(dA|Fd)cDK7_5+3HU!0_a(59i@LJch@o z)On-yUOwfKsNdhiP2BQu5i1POPO0^;dor~Dl>1e Date: Mon, 11 Jan 2021 17:05:03 +0800 Subject: [PATCH 09/61] add comment --- dss-user-manager/src/main/resources/default/Metastore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh index 644796c9e9..c0e197a75e 100644 --- a/dss-user-manager/src/main/resources/default/Metastore.sh +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -12,7 +12,7 @@ hive -e "create database is not exists $db_name" if [[ $? -ne 0 ]]; then echo "create database failed" else - #修改数据库所属,需要hive metastore开启赋权功能,并将hdfs用户添加到admin中 + #修改数据库所属,需要hive metastore开启赋权功能,并将principal用户添加到metastore侧hive-site.xml hive.users.in.admin.role中 hive -e "set role admin ; grant all on database $db_name to user $user_name" fi From ab0d501fcb6ea451582c6d068f15e45e48340ec1 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 11 Jan 2021 17:14:00 +0800 Subject: [PATCH 10/61] New Hostname auto-fetch with Realm configuration definition --- .../dss/user/service/impl/MetastoreCommand.java | 3 ++- .../src/main/resources/default/Metastore.sh | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java index 9de692c1f1..fb454b5f84 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java @@ -25,13 +25,14 @@ private String createDb(AuthorizationBody body, Config parms) throws IOException String bashCommand; String userName = body.getUsername(); + String realm = parms.getString("realm"); String res = null; if (userName != null) { String dbName = userName + parms.getString("db_tail"); String path = parms.getString("base_path") + dbName + ".db"; bashCommand = this.getClass().getClassLoader().getResource(parms.getString("metastore_sh")).getPath(); Runtime runtime = Runtime.getRuntime(); - Process process = runtime.exec("sudo sh " + bashCommand + " " + userName + " " + dbName + "" + path); + Process process = runtime.exec("sudo sh " + bashCommand + " " + userName + " " + dbName + "" + path+ "" + realm); res = CommonFun.process(process); } return res; diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh index c0e197a75e..60d4838a1c 100644 --- a/dss-user-manager/src/main/resources/default/Metastore.sh +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -1,11 +1,13 @@ #!/bin/bash -user_name = $1 -db_name = $2 -path = $3 +user_name=$1 +db_name=$2 +path=$3 +realm=$4 +host_name=`hostname` #一、kerberos认证 -kinit -kt /etc/security/keytabs/${user_name}.keytab ${user_name}/nm-bigdata-030066029.ctc.local@EWS.BIGDATA.CHINATELECOM.CN.UAT +kinit -kt /etc/security/keytabs/${user_name}.keytab ${user_name}/${host_name}@${realm} #二、metastore操作 hive -e "create database is not exists $db_name" From d52e05045cc11269b2e6c4605ef1c6ed00665581 Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 12 Jan 2021 18:22:08 +0800 Subject: [PATCH 11/61] Added keytab key generation function --- .../user/service/impl/KerberosCommand.java | 53 +++++++++++ .../impl/LubanAuthorizationClient.java | 1 + .../user/service/impl/MetastoreCommand.java | 6 +- .../src/main/resources/default/Kerberos.sh | 82 ++++++++++++++++++ .../src/main/resources/default/Metastore.sh | 33 ++++--- .../service/impl/KerberosCommandTest.java | 25 ++++++ .../impl/LubanAuthorizationClient.class | Bin 1019 -> 1111 bytes 7 files changed, 183 insertions(+), 17 deletions(-) create mode 100644 dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java create mode 100644 dss-user-manager/src/main/resources/default/Kerberos.sh create mode 100644 dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommandTest.java diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java new file mode 100644 index 0000000000..10e5e33e54 --- /dev/null +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java @@ -0,0 +1,53 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import com.webank.wedatasphpere.dss.user.service.AbsCommand; +import com.webank.wedatasphpere.dss.user.service.Command; +import com.webank.wedatasphpere.dss.user.service.common.CommonFun; + +import java.io.IOException; +import java.net.InetAddress; + +/** + * @author anlexander + * @date 2021/1/5 + */ +public class KerberosCommand extends AbsCommand { + + @Override + public String authorization(AuthorizationBody body) throws IOException { + Config parms = ConfigFactory.load("config/properties.conf"); + String rst = createKt(body, parms); + return rst != Command.SUCCESS ? rst : Command.SUCCESS; + } + + private String createKt(AuthorizationBody body, Config parms) throws IOException { + + String userName = body.getUsername(); + String hostName = InetAddress.getLocalHost().getHostName(); + String res = null; + if(userName != null){ + res = callShell(parms.getString("shellFile"), userName,hostName, + parms.getString("keytabPath"),parms.getString("sshPort"), + parms.getString("kdcNode"),parms.getString("password"),parms.getString("realm")); + } + return res; + } + + private String callShell(String shellFile, String username, String hostName, String keytabPath, + String sshPort, String kdcNode, String password, String realm) throws IOException{ + + String bashCommand = this.getClass().getClassLoader().getResource(shellFile).getPath(); + String scriptCmd ; + if(null != hostName){ + scriptCmd = String.format("%s %s %s %s %s %s %s %s", bashCommand,username,hostName,keytabPath,sshPort,kdcNode,password,realm); + }else { + scriptCmd = String.format("%s %s %s %s %s %s %s", bashCommand,username,keytabPath,sshPort,kdcNode,password,realm); + } + Process process = Runtime.getRuntime().exec("sudo sh " + scriptCmd); + return CommonFun.process(process); + } + +} diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java index 9ebe720a6b..16aceca85a 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.java @@ -16,6 +16,7 @@ public class LubanAuthorizationClient { public LubanAuthorizationClient(){ lubanCommand.add(new WorkspaceCommand()); lubanCommand.add(new MetastoreCommand()); + lubanCommand.add(new KerberosCommand()); } public String authorization(AuthorizationBody body) { diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java index fb454b5f84..67330b257f 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java @@ -25,14 +25,14 @@ private String createDb(AuthorizationBody body, Config parms) throws IOException String bashCommand; String userName = body.getUsername(); - String realm = parms.getString("realm"); String res = null; if (userName != null) { String dbName = userName + parms.getString("db_tail"); String path = parms.getString("base_path") + dbName + ".db"; bashCommand = this.getClass().getClassLoader().getResource(parms.getString("metastore_sh")).getPath(); - Runtime runtime = Runtime.getRuntime(); - Process process = runtime.exec("sudo sh " + bashCommand + " " + userName + " " + dbName + "" + path+ "" + realm); + String scriptCmd = String.format("%s %s %s %s %s %s %s", bashCommand,userName,dbName,path, + parms.getString("realm"),parms.getString("admin"),parms.getString("keytabPath")); + Process process = Runtime.getRuntime().exec("sudo sh " + scriptCmd); res = CommonFun.process(process); } return res; diff --git a/dss-user-manager/src/main/resources/default/Kerberos.sh b/dss-user-manager/src/main/resources/default/Kerberos.sh new file mode 100644 index 0000000000..7a2612b4f6 --- /dev/null +++ b/dss-user-manager/src/main/resources/default/Kerberos.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +#函数 +check_principal_exist(){ + all_principal=`timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo /usr/sbin/kadmin.local -q \"list_principals\""` #echo "all_principal:"$all_principal + principal=$1 + if [[ $all_principal =~ $principal ]] + then + #echo "包含" + return 1 + else + #echo "不包含" + return 0 + fi +} + +add_principal(){ + principalPrefix=$1 + echo "add_principal func,principalPrefix:"$principalPrefix + check_principal_exist "$principalPrefix@$REALM" + ifexist=$? + if [ $ifexist -eq 1 ] + then + echo "已有principal" + else + echo "没有principal,将会生成" + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo /usr/sbin/kadmin.local -q \"addprinc -randkey $principalPrefix\"" + fi +} + +gen_keytab(){ + user=$1 + host=$2 + principalPrefix="$user/$host" + principal="$user/$host@$REALM" + add_principal $principalPrefix + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo rm -rf /tmp/$host.$user.keytab" + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo /usr/sbin/kadmin.local -q \"xst -norandkey -k /tmp/$host.$user.keytab $user/$host\"" + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo chmod 755 /tmp/$host.$user.keytab" + timeout 30 sshpass -p $PASSWORD scp -P $SSH_PORT $KDCSERVER:/tmp/$host.$user.keytab $CENTER_KEYTAB_PATHs +} + +gen_keytab_user(){ + user=$1 + principalPrefix="$user" + principal="$user@$REALM" + add_principal $principalPrefix + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo rm -rf /tmp/$user.keytab" + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo /usr/sbin/kadmin.local -q \"xst -norandkey -k /tmp/$user.keytab $user\"" + timeout 30 sshpass -p $PASSWORD ssh -p $SSH_PORT $KDCSERVER "sudo chmod 755 /tmp/$user.keytab" + timeout 30 sshpass -p $PASSWORD scp -P $SSH_PORT $KDCSERVER:/tmp/$user.keytab $CENTER_KEYTAB_PATH +} + +#第一个参数为功能参数(必须有),第二个为user(必须有),第三个为host(可以有) +if [ $# -lt 2 ] || [ $# -gt 7 ]; then + echo -e "\033[31m \033[05m请确认您的操作,输入格式如下 功能参数 [user|user hostname]\033[0m" + echo "Usage: $0 genenateKeytab {username|username hostname}" + echo `date '+%Y-%m-%d %H:%M:%S'`" parameters:"$* >>/tmp/deltaKerberos.log + exit 1 +else + if [ $# -eq 2 ]; then + user=$1 + CENTER_KEYTAB_PATH=$2 + SSH_PORT=$3 + KDCSERVER=$4 + PASSWORD=$5 + REALM=$6 + echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user >>/tmp/deltaKerberos.log + gen_keytab_user $user + else + user=$1 + host=$2 + CENTER_KEYTAB_PATH=$3 + SSH_PORT=$4 + KDCSERVER=$5 + PASSWORD=$6 + REALM=$7 + echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user" hostname:"$host >>/tmp/deltaKerberos.log + gen_keytab $user $host + fi +fi +exit 0 \ No newline at end of file diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh index 60d4838a1c..a0f1823650 100644 --- a/dss-user-manager/src/main/resources/default/Metastore.sh +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -4,27 +4,32 @@ user_name=$1 db_name=$2 path=$3 realm=$4 +admin=$5 +ktPath=$6 host_name=`hostname` -#一、kerberos认证 -kinit -kt /etc/security/keytabs/${user_name}.keytab ${user_name}/${host_name}@${realm} + #一、kerberos认证 +kinit -kt $ktPath/$admin.keytab hdfs/${host_name}@${realm} -#二、metastore操作 -hive -e "create database is not exists $db_name" + #二、metastore操作 +hive -e "create database if not exists $db_name" if [[ $? -ne 0 ]]; then - echo "create database failed" + echo "create database failed!" else - #修改数据库所属,需要hive metastore开启赋权功能,并将principal用户添加到metastore侧hive-site.xml hive.users.in.admin.role中 + #修改数据库所属,将principal用户添加到metastore侧hive-site.xml hive.users.in.admin.role中 hive -e "set role admin ; grant all on database $db_name to user $user_name" + echo "grant database $db_name successfully!" fi -#三、hdfs操作 + #三、hdfs操作 if [[ $? -ne 0 ]]; then - #修改hdfs路径所属 - hdfs dfs -chown $user_name:$user_name $path - #修改hdfs路径权限 - hdfs dfs -chmod -R 700 $user_name -else - #回滚 + #回滚 hive -e "drop database $db_name" -fi \ No newline at end of file + echo "rollback finished!" +else + #修改hdfs路径所属 + hdfs dfs -chown $user_name:$user_name $path + #修改hdfs路径权限 + hdfs dfs -chmod -R 700 $path + echo "hdfs operation successfully!" +fi diff --git a/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommandTest.java b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommandTest.java new file mode 100644 index 0000000000..a8e13e7bbc --- /dev/null +++ b/dss-user-manager/src/test/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommandTest.java @@ -0,0 +1,25 @@ +package com.webank.wedatasphpere.dss.user.service.impl; + + +import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +class KerberosCommandTest { + + @Test +// @MethodSource("body") + void authorization() { + AuthorizationBody body = new AuthorizationBody(); + body.setUsername("anlexander"); + body.setPassword("123321"); + KerberosCommand test = new KerberosCommand(); + try { + test.authorization(body); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("当前测试方法结束"); + } +} \ No newline at end of file diff --git a/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class b/dss-user-manager/target/classes/com/webank/wedatasphpere/dss/user/service/impl/LubanAuthorizationClient.class index 1675ae5c39d0cb10391bf4bd38b9e4dba61677cd..9ce5db71abed33e479997bba89aba69dbfbffac9 100644 GIT binary patch delta 323 zcmXYrO-jR16otRM)Vw6ER-;Y*N&MG>6`XXaI1q;}KxYN(tQNH3&^46oz!g}K3JMM# zICADXT4$fb~w1{oecW@?)7Djm}WLI53Q;S z!4X_pZAQCjnsZWDxY}SpyKvL{y(cQK_~*|A6YRKfN1CzzhcXor>dK`=w3*jK^dip! t4Jjw@{bwJk%jg#5*!G0*QNkz+UJ;55KwO#xXyyd@S!78Dhh-_l${!pEC2Rly delta 307 zcmXYrJx;?=5QM+?{PSYR32{OK7?SW;nIcWfAWYg)txV#YtwT)5_3C#}T9cb=_iy@*(K YKwPJWb;GDJ{Wr+Yh#l<>yS0Ds53PV63;+NC From 6b1098fd9258290e3a77c93bfef5e279862b08e1 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Fri, 8 Jan 2021 15:44:00 +0800 Subject: [PATCH 12/61] entry of super admin --- .../dss/application/conf/ApplicationConf.java | 2 +- .../resources/default/AddschedulerUser.sh | 13 ++++++++++ .../src/main/resources/default/HdfsPath.sh | 4 +-- .../src/main/resources/default/LinuxPath.sh | 6 ++--- web/src/commonData/i18n/common/en.json | 3 ++- web/src/commonData/i18n/common/zh.json | 3 ++- web/src/js/module/header/userMenu.vue | 25 ++++++++++++++----- 7 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 dss-user-manager/src/main/resources/default/AddschedulerUser.sh diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java index 3d14c7c378..2c4159aeff 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/conf/ApplicationConf.java @@ -32,7 +32,7 @@ public class ApplicationConf { public static final String HDFS_USER_ROOT_PATH = CommonVars.apply("wds.linkis.hdfs.user.root.path","").getValue(); public static final String RESULT_SET_ROOT_PATH = CommonVars.apply("wds.linkis.result.set.root.path","").getValue(); public static final String WDS_SCHEDULER_PATH = CommonVars.apply("wds.linkis.scheduler.path","").getValue(); - public static final String WDS_USER_PATH = CommonVars.apply("wds.linkis.user.path","user").getValue(); + public static final String WDS_USER_PATH = CommonVars.apply("wds.linkis.user.path","hdfs:///user").getValue(); diff --git a/dss-user-manager/src/main/resources/default/AddschedulerUser.sh b/dss-user-manager/src/main/resources/default/AddschedulerUser.sh new file mode 100644 index 0000000000..18eb785b61 --- /dev/null +++ b/dss-user-manager/src/main/resources/default/AddschedulerUser.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +user=$1 +password=$2 +installDir=$3 + + +if grep -i "^${user}=" $installDir/linkis.properties; + then + sed -i '' "s/^$user=.*/$user=$password/" $installDir/linkis.properties +else + echo "$user=$password" >> $installDir/linkis.properties +fi diff --git a/dss-user-manager/src/main/resources/default/HdfsPath.sh b/dss-user-manager/src/main/resources/default/HdfsPath.sh index dffe821128..5b1fa2468c 100644 --- a/dss-user-manager/src/main/resources/default/HdfsPath.sh +++ b/dss-user-manager/src/main/resources/default/HdfsPath.sh @@ -1,6 +1,6 @@ #!/bin/bash user=$1 -dic=$2 -hdfs dfs -mkdir $dic +dir=$2 +hdfs dfs -mkdir $dir hdfs dfs -chown $user:$user \ No newline at end of file diff --git a/dss-user-manager/src/main/resources/default/LinuxPath.sh b/dss-user-manager/src/main/resources/default/LinuxPath.sh index 26fc03de5e..bc55860b10 100644 --- a/dss-user-manager/src/main/resources/default/LinuxPath.sh +++ b/dss-user-manager/src/main/resources/default/LinuxPath.sh @@ -1,7 +1,7 @@ #!/bin/bash user=$1 -dic=$2 +dir=$2 echo $1 $2; -sudo mkdir -p $dic -sudo chown $user:$user $dic \ No newline at end of file +sudo mkdir -p $dir +sudo chown $user:$user $dir \ No newline at end of file diff --git a/web/src/commonData/i18n/common/en.json b/web/src/commonData/i18n/common/en.json index f0e29bbba5..4370f0ed6f 100644 --- a/web/src/commonData/i18n/common/en.json +++ b/web/src/commonData/i18n/common/en.json @@ -634,7 +634,8 @@ "navMune": { "FAQ": "FAQ", "clearCache": "Clear cache", - "logOut": "Log out" + "logOut": "Log out", + "userManager": "User Manager" }, "shape": { "dataDev": "Data development", diff --git a/web/src/commonData/i18n/common/zh.json b/web/src/commonData/i18n/common/zh.json index 5a17a2a350..a38fb6f584 100644 --- a/web/src/commonData/i18n/common/zh.json +++ b/web/src/commonData/i18n/common/zh.json @@ -634,7 +634,8 @@ "navMune": { "FAQ": "常见问题", "clearCache": "清理缓存", - "logOut": "退出登录" + "logOut": "退出登录", + "userManager": "用户管理" }, "shape": { "dataDev": "数据开发", diff --git a/web/src/js/module/header/userMenu.vue b/web/src/js/module/header/userMenu.vue index 1df8fe5424..42c2e83c1a 100644 --- a/web/src/js/module/header/userMenu.vue +++ b/web/src/js/module/header/userMenu.vue @@ -17,16 +17,12 @@ - - - diff --git a/web/vue.config.js b/web/vue.config.js index 76e23f7ba5..9f72df52ae 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -29,10 +29,8 @@ const getVersion = () => { return pkg.version; } -// const host = "0.0.0.0"; -// const port = "9001"; -const host = "***REMOVED***"; -const port = "8088"; +const host = "0.0.0.0"; +const port = "9001"; module.exports = { publicPath: './', @@ -82,7 +80,7 @@ module.exports = { } }, configureWebpack: { - devtool: 'eval-source-map', + devtool: process.env.NODE_ENV === 'development' ? 'eval-source-map' : '', resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js', From f5d8bb8e5364802967bc8144663f752845a58b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B8=E6=B5=B7=E6=B4=8B?= Date: Thu, 4 Feb 2021 13:51:35 +0800 Subject: [PATCH 40/61] up --- .vscode/settings.json | 5 + web/.eslintrc.js | 24 +-- web/src/js/view/userManager/index.vue | 235 ++++++++++++++------------ web/vue.config.js | 7 +- 4 files changed, 150 insertions(+), 121 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..0a9b7a79be --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.formatOnPaste": true, + "editor.formatOnType": true, + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 4dd116dc92..bfa603d522 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -37,13 +37,13 @@ module.exports = { 'keyword-spacing': 0, 'no-useless-escape': 0, 'operator-linebreak': 0, - // 'indent': [ - // 'error', - // 2, - // { - // 'SwitchCase': 1 - // } - // ], + 'indent': [ + 'error', + 2, + { + 'SwitchCase': 1 + } + ], 'no-const-assign': 'warn', 'no-this-before-super': 'warn', 'no-undef': 2, @@ -63,11 +63,11 @@ module.exports = { 'invalid-first-character-of-tag-name': false }], 'no-tabs': 0, - // 'vue/html-indent': [2, 2, { - // 'attribute': 1, - // 'closeBracket': 0, - // 'alignAttributesVertically': false - // }], + 'vue/html-indent': [2, 2, { + 'attribute': 1, + 'closeBracket': 0, + 'alignAttributesVertically': false + }], 'vue/require-default-prop': 0, 'vue/component-name-in-template-casing': 0, 'vue/html-closing-bracket-spacing': 0, diff --git a/web/src/js/view/userManager/index.vue b/web/src/js/view/userManager/index.vue index fcef6ec0d9..0df7bc7b2f 100644 --- a/web/src/js/view/userManager/index.vue +++ b/web/src/js/view/userManager/index.vue @@ -5,18 +5,16 @@

{{ $t("message.userManager.createUser") }}

-
+
- + > - + >
-
+
- + - + - - + + + +
-
+
@@ -90,150 +85,178 @@ - +
- - - - - + >{{ $t("message.constants.submit") }} + + + + + + + + + + - +
diff --git a/web/vue.config.js b/web/vue.config.js index 9f72df52ae..558b04caea 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -29,9 +29,10 @@ const getVersion = () => { return pkg.version; } -const host = "0.0.0.0"; -const port = "9001"; - +// const host = "0.0.0.0"; +// const port = "9001"; +const host = "***REMOVED***"; +const port = "8088"; module.exports = { publicPath: './', outputDir: 'dist/dist', From 9f362a7c8ccd8479c50039195080725be4280316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B8=E6=B5=B7=E6=B4=8B?= Date: Thu, 4 Feb 2021 14:18:14 +0800 Subject: [PATCH 41/61] Add a password strength check --- web/src/commonData/i18n/common/en.json | 1 + web/src/commonData/i18n/common/zh.json | 1 + web/src/js/view/userManager/index.vue | 6 ++---- web/vue.config.js | 6 ++---- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/web/src/commonData/i18n/common/en.json b/web/src/commonData/i18n/common/en.json index aa20b540b0..f68f2e82d3 100644 --- a/web/src/commonData/i18n/common/en.json +++ b/web/src/commonData/i18n/common/en.json @@ -1675,6 +1675,7 @@ "schedulerPath": "Scheduler root Path", "usernameNotNull": "username cannot be empty", "passwordNotNull": "password cannot be empty", + "passwordNotWeak": "password begins with a letter, contains letters, numbers, and special characters, not less than 8 digits", "createSuccess": "create user Success", "createFail": "create user Fail", "dssInstallDir": "dss install directory", diff --git a/web/src/commonData/i18n/common/zh.json b/web/src/commonData/i18n/common/zh.json index dd41b015aa..433eb0c74e 100644 --- a/web/src/commonData/i18n/common/zh.json +++ b/web/src/commonData/i18n/common/zh.json @@ -1675,6 +1675,7 @@ "schedulerPath": "调度存储根目录", "usernameNotNull": "用户名不能为空", "passwordNotNull": "密码不能为空", + "passwordNotWeak": "密码以字母开头,含有字母、数字和特殊字符,不少于8位", "createSuccess": "创建账号成功", "createFail": "创建账号失败", "dssInstallDir": "DSS 安装目录", diff --git a/web/src/js/view/userManager/index.vue b/web/src/js/view/userManager/index.vue index 0df7bc7b2f..aae1c6af12 100644 --- a/web/src/js/view/userManager/index.vue +++ b/web/src/js/view/userManager/index.vue @@ -148,7 +148,7 @@ export default { specialChar.test(value) ) ) { - callback(new Error('qqq')) + callback(new Error(this.$t('message.userManager.passwordNotWeak'))) } else { callback() } @@ -175,7 +175,6 @@ export default { password: [ { required: true, - //message: this.$t("message.userManager.passwordNotNull"), trigger: 'blur', validator: validatePwd, }, @@ -201,7 +200,6 @@ export default { handleSubmit(name) { this.confirmLoading = true this.$refs[name].validate((valid) => { - return if (valid) { const { servers, ...rest } = this.formCreateUser const validServers = servers.filter((item) => { @@ -214,7 +212,7 @@ export default { validServers.length > 0 ? { ...rest, servers: validServers } : rest, - null, + {method: 'post', timeout: 120000}, 5 ) .then((rst) => { diff --git a/web/vue.config.js b/web/vue.config.js index 558b04caea..91b20f3891 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -29,10 +29,8 @@ const getVersion = () => { return pkg.version; } -// const host = "0.0.0.0"; -// const port = "9001"; -const host = "***REMOVED***"; -const port = "8088"; +const host = "0.0.0.0"; +const port = "9001"; module.exports = { publicPath: './', outputDir: 'dist/dist', From f691de45cd3733cc09c789b2506c03208d18aa6b Mon Sep 17 00:00:00 2001 From: hantang Date: Fri, 19 Feb 2021 19:30:55 +0800 Subject: [PATCH 42/61] script modification --- .../main/resources/default/CreateLinuxUser.sh | 35 +++++++++++++++++++ .../resources/default/CreateLdapAccount.sh | 5 +++ .../main/resources/default/CreateLinuxUser.sh | 8 ++--- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 dss-server/src/main/resources/default/CreateLinuxUser.sh diff --git a/dss-server/src/main/resources/default/CreateLinuxUser.sh b/dss-server/src/main/resources/default/CreateLinuxUser.sh new file mode 100644 index 0000000000..fabcac1c5a --- /dev/null +++ b/dss-server/src/main/resources/default/CreateLinuxUser.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +source /etc/profile +server_user_strs=$1 +echo $server_user_strs +add_user_name=$2 +add_user_password=$3 +server_user_array=(${server_user_strs//,/ }) +for server_user_str in ${server_user_array[@]} +do + server_user_info=(${server_user_str//#/ }) + server_host=${server_user_info[0]} + server_user_name=${server_user_info[1]} + server_user_password=${server_user_info[2]} + echo "${server_host},${server_user_name},${server_user_password}" + + sudo sshpass -p $server_user_password ssh -o ConnectTimeout=1 $server_user_name@$server_host "echo success" + [ $? -ne 0 ] && echo "登录主机${server_host}失败" && exit 254 +done + +echo "************服务器网络校验通过,开始创建用户*****************" + +for server_user_str in ${server_user_array[@]} +do + + server_user_info=(${server_user_str//#/ }) + server_host=${server_user_info[0]} + server_user_name=${server_user_info[1]} + server_user_password=${server_user_info[2]} + + #sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name && echo $add_user_password |sudo -i passwd --stdin $add_user_name" + sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name -s /sbin/nologin" + + [ $? -ne 0 ] && echo "创建用户失败:${host}失败" && exit 254 +done diff --git a/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh b/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh index 3e15552da7..1318ab16b7 100644 --- a/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh +++ b/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh @@ -9,5 +9,10 @@ ldap_user=$6 ldap_password=$7 echo "$server_login_password ssh $server_login_user@$server_host sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password" sshpass -p $server_login_password ssh $server_login_user@$server_host "sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password" +#sshpass -p $server_login_password ssh $server_login_user@$server_host "sudo su - root -c 'source /etc/profile && source $server_ldap_source_path && sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password && deactivate'" echo "******************LDAP USER CREATED***********************" + + + + diff --git a/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh b/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh index cfc236411a..fabcac1c5a 100644 --- a/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh +++ b/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh @@ -1,4 +1,5 @@ #!/bin/bash + source /etc/profile server_user_strs=$1 echo $server_user_strs @@ -26,10 +27,9 @@ do server_host=${server_user_info[0]} server_user_name=${server_user_info[1]} server_user_password=${server_user_info[2]} - sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name -s /sbin/nologin" - #sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name && echo $add_user_password |sudo -i passwd --stdin $add_user_name" - #|sudo -i passwd --stdin $add_user_name + #sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name && echo $add_user_password |sudo -i passwd --stdin $add_user_name" + sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name -s /sbin/nologin" + [ $? -ne 0 ] && echo "创建用户失败:${host}失败" && exit 254 done - From 14752435f69b6041efb8d9bb3d6f583e72115ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B8=E6=B5=B7=E6=B4=8B?= Date: Thu, 18 Feb 2021 09:32:58 +0800 Subject: [PATCH 43/61] Add a password strength check --- web/src/commonData/i18n/common/en.json | 10 +- web/src/commonData/i18n/common/zh.json | 10 +- web/src/js/view/userManager/index.vue | 125 ++++++++++++++++++++++--- web/vue.config.js | 6 +- 4 files changed, 134 insertions(+), 17 deletions(-) diff --git a/web/src/commonData/i18n/common/en.json b/web/src/commonData/i18n/common/en.json index f68f2e82d3..02a3bf13e7 100644 --- a/web/src/commonData/i18n/common/en.json +++ b/web/src/commonData/i18n/common/en.json @@ -1674,6 +1674,7 @@ "resultPath": "Result root Path", "schedulerPath": "Scheduler root Path", "usernameNotNull": "username cannot be empty", + "usernameFormat": "username begins with a letter, contains only letters, numbers, or underscores", "passwordNotNull": "password cannot be empty", "passwordNotWeak": "password begins with a letter, contains letters, numbers, and special characters, not less than 8 digits", "createSuccess": "create user Success", @@ -1683,12 +1684,19 @@ "linuxHost" : "linuxHost", "linuxLoginUser" : "linuxLoginUser", "linuxLoginPassword" : "linuxLoginPassword", + "linuxHostNotNull" : "linuxHost cannot be empty", + "linuxLoginUserNotNull" : "linuxLoginUser cannot be empty", + "linuxLoginPasswordNotNull" : "linuxLoginPassword cannot be empty", "serverSettings": "serverSettings", "userSettings": "userSettings", "XYB": "Next step", "SYB": "Previous step", "addServer": "Add server", - "deleteTip": "Are you sure you want to delete this server?" + "deleteTip": "Are you sure you want to delete this server?", + "serverSame": " server's host and user is the same, please keep one server with the same configuration", + "serverNull": "The server configuration option cannot be empty", + "pathNotNull": "Cannot be empty", + "createTip": "It will take some time to create, please wait patiently, if successful, return to the home page, fail to stay on this page" } } } \ No newline at end of file diff --git a/web/src/commonData/i18n/common/zh.json b/web/src/commonData/i18n/common/zh.json index 433eb0c74e..98d0946695 100644 --- a/web/src/commonData/i18n/common/zh.json +++ b/web/src/commonData/i18n/common/zh.json @@ -1674,6 +1674,7 @@ "resultPath": "结果存储根目录", "schedulerPath": "调度存储根目录", "usernameNotNull": "用户名不能为空", + "usernameFormat": "账号以字母开头,仅能含有字母、数字或者下划线", "passwordNotNull": "密码不能为空", "passwordNotWeak": "密码以字母开头,含有字母、数字和特殊字符,不少于8位", "createSuccess": "创建账号成功", @@ -1683,12 +1684,19 @@ "linuxHost" : "服务器ip", "linuxLoginUser" : "服务器用户名", "linuxLoginPassword" : "服务器密码", + "linuxHostNotNull" : "服务器ip不能为空", + "linuxLoginUserNotNull" : "服务器用户名不能为空", + "linuxLoginPasswordNotNull" : "服务器密码不能为空", "serverSettings": "服务器配置", "userSettings": "用户配置", "XYB": "下一步", "SYB": "上一步", "addServer": "添加服务器", - "deleteTip": "确认删除该服务器?" + "deleteTip": "确认删除该服务器?", + "serverSame": " 服务器ip与用户名配置相同,相同配置的服务器只能保留一个", + "serverNull": "服务器配置选项不能为空", + "pathNotNull": "不能为空", + "createTip": "创建需要一段时间,请耐心等候,如果成功则返回首页,失败则停留本页" } } } \ No newline at end of file diff --git a/web/src/js/view/userManager/index.vue b/web/src/js/view/userManager/index.vue index aae1c6af12..f25c71ffb8 100644 --- a/web/src/js/view/userManager/index.vue +++ b/web/src/js/view/userManager/index.vue @@ -17,11 +17,10 @@ >
+
+ {{index + 1 }} +
- +
- + - + - + - + @@ -70,6 +84,14 @@
+
+
@@ -85,8 +107,9 @@ - - + +
@@ -153,6 +176,16 @@ export default { callback() } } + const validateUser = (rule, value, callback) => { + const userReg = /^[A-Za-z][A-Za-z0-9_]*$/; + if (!value) { + callback(new Error(this.$t('message.userManager.usernameNotNull'))) + } else if (!userReg.test(value)) { + callback(new Error(this.$t('message.userManager.usernameFormat'))) + } else { + callback() + } + } return { formCreateUser: { username: '', @@ -168,8 +201,8 @@ export default { username: [ { required: true, - message: this.$t('message.userManager.usernameNotNull'), trigger: 'blur', + validator: validateUser, }, ], password: [ @@ -198,9 +231,18 @@ export default { }, methods: { handleSubmit(name) { + const paths = this.formCreateUser.paths; + paths.forEach(item => { + item.value = item.value && item.value.trim(); + }) + this.formCreateUser.paths = paths; this.confirmLoading = true this.$refs[name].validate((valid) => { if (valid) { + this.$Message.info({ + content: this.$t('message.userManager.createTip'), + duration: 20 + }); const { servers, ...rest } = this.formCreateUser const validServers = servers.filter((item) => { return Object.keys(item).every((key) => !!item[key]) @@ -225,6 +267,7 @@ export default { this.$Message.success( this.$t('message.userManager.createSuccess') ) + this.$router.push('/') } }) .catch((err) => { @@ -240,7 +283,63 @@ export default { }, setStep(action) { if (action === 'next') { - this.active = this.active + 1 + + this.formCreateUser.servers =this.formCreateUser.servers.map(server => { + const obj = {...server}; + Object.keys(server).forEach(key => {obj[key] = obj[key] && obj[key].trim()} ); + return obj + + }); + this.$refs["createServerForm"].validate(valid => { + + if(valid){ + const servers = this.formCreateUser.servers; + //检测服务器ip与用户名是否有完全相同的 + if(servers.length > 1){ + const serversTemp = servers.map(server => { + const arr = Object.keys(server).map(key => { + if(key !== 'linuxLoginPassword'){ + return key + server[key]; + } + return ""; + }); + return arr.join("$--$"); + }); + const hadIn = []; + const repeats = []; + for(let i =0; i< serversTemp.length; i++){ + if(!hadIn.includes(i)){ + hadIn.push(i); + const str = serversTemp[i]; + const ar = [i + 1]; + for(let j = i + 1; j < serversTemp.length; j++){ + const str2 = serversTemp[j]; + if(str === str2){ + ar.push(j + 1); + hadIn.push(j); + } + } + if(ar.length > 1){ + repeats.push(ar.join(',')); + } + } + + } + if(repeats.length > 0){ + this.$Message.error({content: repeats.join(" / ") + this.$t('message.userManager.serverSame'), duration: 6}); + return + } + + + } + + this.active = this.active + 1; + + }else{ + this.$Message.error(this.$t('message.userManager.serverNull')) + } + }) + } else { this.active = this.active - 1 } diff --git a/web/vue.config.js b/web/vue.config.js index 91b20f3891..558b04caea 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -29,8 +29,10 @@ const getVersion = () => { return pkg.version; } -const host = "0.0.0.0"; -const port = "9001"; +// const host = "0.0.0.0"; +// const port = "9001"; +const host = "***REMOVED***"; +const port = "8088"; module.exports = { publicPath: './', outputDir: 'dist/dist', From 5f5e54a735fe1d56e3fd47bb0df1166d5c4b5ec5 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Fri, 19 Feb 2021 09:48:20 +0800 Subject: [PATCH 44/61] Fixed missing packaging issues --- dss-server/pom.xml | 5 +++++ dss-server/src/main/assembly/distribution.xml | 18 ++++++++++++++++++ .../src/main/resources/linkis.properties | 18 ------------------ 3 files changed, 23 insertions(+), 18 deletions(-) delete mode 100644 dss-user-manager/src/main/resources/linkis.properties diff --git a/dss-server/pom.xml b/dss-server/pom.xml index 957327a04e..8030b5b056 100644 --- a/dss-server/pom.xml +++ b/dss-server/pom.xml @@ -172,6 +172,11 @@ config 1.4.1 + + xml-apis + xml-apis + 1.4.01 + diff --git a/dss-server/src/main/assembly/distribution.xml b/dss-server/src/main/assembly/distribution.xml index 0c7f789ee4..0da5c182ca 100644 --- a/dss-server/src/main/assembly/distribution.xml +++ b/dss-server/src/main/assembly/distribution.xml @@ -300,6 +300,24 @@ conf unix + + ${project.parent.basedir}/dss-user-manager/src/main/resources/config + + * + + 0777 + conf/config + unix + + + ${project.parent.basedir}/dss-user-manager/src/main/resources/default + + * + + 0777 + conf/default + unix + ${basedir}/bin diff --git a/dss-user-manager/src/main/resources/linkis.properties b/dss-user-manager/src/main/resources/linkis.properties deleted file mode 100644 index d1ac907e5a..0000000000 --- a/dss-user-manager/src/main/resources/linkis.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright 2019 WeBank -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -wds.dss.user.root.dir=file:///appcom/tmp/wds/scheduler From 88a411b113dd8c58356b60e2330d7a0b83c08625 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Fri, 19 Feb 2021 09:55:59 +0800 Subject: [PATCH 45/61] Modify version number --- assembly/pom.xml | 2 +- conf/config.sh | 2 +- datachecker-appjoint/pom.xml | 2 +- docs/en_US/ch1/DataSphereStudio_Compile_Manual.md | 2 +- .../DSS\347\274\226\350\257\221\346\226\207\346\241\243.md" | 2 +- dss-appjoint-auth/pom.xml | 2 +- dss-appjoint-core/pom.xml | 2 +- dss-appjoint-loader/pom.xml | 4 ++-- dss-application/pom.xml | 2 +- dss-azkaban-scheduler-appjoint/pom.xml | 2 +- dss-common/pom.xml | 2 +- dss-flow-execution-entrance/pom.xml | 2 +- dss-linkis-node-execution/pom.xml | 2 +- dss-scheduler-appjoint-core/pom.xml | 2 +- dss-server/pom.xml | 6 +++--- dss-user-manager/pom.xml | 2 +- eventchecker-appjoint/pom.xml | 2 +- plugins/azkaban/linkis-jobtype/pom.xml | 2 +- plugins/linkis/linkis-appjoint-entrance/pom.xml | 2 +- pom.xml | 4 ++-- qualitis-appjoint/appjoint/pom.xml | 2 +- sendemail-appjoint/sendemail-core/pom.xml | 2 +- visualis-appjoint/appjoint/pom.xml | 2 +- web/package.json | 2 +- 24 files changed, 28 insertions(+), 28 deletions(-) diff --git a/assembly/pom.xml b/assembly/pom.xml index 3aa0e2d9a4..5395815964 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/conf/config.sh b/conf/config.sh index c6d910aca9..74c913ddc6 100644 --- a/conf/config.sh +++ b/conf/config.sh @@ -77,4 +77,4 @@ AZKABAN_ADRESS_PORT=8081 QUALITIS_ADRESS_IP=127.0.0.1 QUALITIS_ADRESS_PORT=8090 -DSS_VERSION=0.9.0 +DSS_VERSION=0.9.1 diff --git a/datachecker-appjoint/pom.xml b/datachecker-appjoint/pom.xml index 9d36a02ae5..d609c3ab32 100644 --- a/datachecker-appjoint/pom.xml +++ b/datachecker-appjoint/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/docs/en_US/ch1/DataSphereStudio_Compile_Manual.md b/docs/en_US/ch1/DataSphereStudio_Compile_Manual.md index 598ff158b8..d1b5408a2f 100644 --- a/docs/en_US/ch1/DataSphereStudio_Compile_Manual.md +++ b/docs/en_US/ch1/DataSphereStudio_Compile_Manual.md @@ -6,7 +6,7 @@ ```xml - 0.9.0 + 0.9.1 0.9.4 2.11.8 1.8 diff --git "a/docs/zh_CN/ch1/DSS\347\274\226\350\257\221\346\226\207\346\241\243.md" "b/docs/zh_CN/ch1/DSS\347\274\226\350\257\221\346\226\207\346\241\243.md" index 6ac3ece635..e89a29638d 100644 --- "a/docs/zh_CN/ch1/DSS\347\274\226\350\257\221\346\226\207\346\241\243.md" +++ "b/docs/zh_CN/ch1/DSS\347\274\226\350\257\221\346\226\207\346\241\243.md" @@ -6,7 +6,7 @@ ```xml - 0.9.0 + 0.9.1 0.9.4 2.11.8 1.8 diff --git a/dss-appjoint-auth/pom.xml b/dss-appjoint-auth/pom.xml index 941a120d1c..3a368b8666 100644 --- a/dss-appjoint-auth/pom.xml +++ b/dss-appjoint-auth/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/dss-appjoint-core/pom.xml b/dss-appjoint-core/pom.xml index 6ee707c4dd..7140b33656 100644 --- a/dss-appjoint-core/pom.xml +++ b/dss-appjoint-core/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/dss-appjoint-loader/pom.xml b/dss-appjoint-loader/pom.xml index b36ab5d799..99ab6ac8be 100644 --- a/dss-appjoint-loader/pom.xml +++ b/dss-appjoint-loader/pom.xml @@ -22,12 +22,12 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 dss-appjoint-loader - 0.9.0 + 0.9.1 diff --git a/dss-application/pom.xml b/dss-application/pom.xml index e2b32c0793..8be0e04348 100644 --- a/dss-application/pom.xml +++ b/dss-application/pom.xml @@ -23,7 +23,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 dss-application diff --git a/dss-azkaban-scheduler-appjoint/pom.xml b/dss-azkaban-scheduler-appjoint/pom.xml index f7a82d5557..4f67a636b8 100644 --- a/dss-azkaban-scheduler-appjoint/pom.xml +++ b/dss-azkaban-scheduler-appjoint/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/dss-common/pom.xml b/dss-common/pom.xml index fb77c4dad1..4fe637f11b 100644 --- a/dss-common/pom.xml +++ b/dss-common/pom.xml @@ -23,7 +23,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 dss-common diff --git a/dss-flow-execution-entrance/pom.xml b/dss-flow-execution-entrance/pom.xml index 7e152ced39..669ca30cd5 100644 --- a/dss-flow-execution-entrance/pom.xml +++ b/dss-flow-execution-entrance/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/dss-linkis-node-execution/pom.xml b/dss-linkis-node-execution/pom.xml index 0e8eb4e823..f773b12f24 100644 --- a/dss-linkis-node-execution/pom.xml +++ b/dss-linkis-node-execution/pom.xml @@ -24,7 +24,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 dss-linkis-node-execution diff --git a/dss-scheduler-appjoint-core/pom.xml b/dss-scheduler-appjoint-core/pom.xml index 979a90903e..72f112372a 100644 --- a/dss-scheduler-appjoint-core/pom.xml +++ b/dss-scheduler-appjoint-core/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/dss-server/pom.xml b/dss-server/pom.xml index 8030b5b056..76d1446ddb 100644 --- a/dss-server/pom.xml +++ b/dss-server/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 @@ -149,12 +149,12 @@ com.webank.wedatasphere.dss dss-scheduler-appjoint-core - 0.9.0 + 0.9.1 com.webank.wedatasphere.dss dss-user-manager - 0.9.0 + 0.9.1 compile diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml index 07efe4a2b9..83d0def7bd 100644 --- a/dss-user-manager/pom.xml +++ b/dss-user-manager/pom.xml @@ -5,7 +5,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/eventchecker-appjoint/pom.xml b/eventchecker-appjoint/pom.xml index 3ae6e8f70b..bdf035e3db 100644 --- a/eventchecker-appjoint/pom.xml +++ b/eventchecker-appjoint/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/plugins/azkaban/linkis-jobtype/pom.xml b/plugins/azkaban/linkis-jobtype/pom.xml index c1c697d8ca..9d0d787b5a 100644 --- a/plugins/azkaban/linkis-jobtype/pom.xml +++ b/plugins/azkaban/linkis-jobtype/pom.xml @@ -23,7 +23,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 com.webank.wedatasphere.dss linkis-jobtype diff --git a/plugins/linkis/linkis-appjoint-entrance/pom.xml b/plugins/linkis/linkis-appjoint-entrance/pom.xml index 12a064427e..bb7db19018 100644 --- a/plugins/linkis/linkis-appjoint-entrance/pom.xml +++ b/plugins/linkis/linkis-appjoint-entrance/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/pom.xml b/pom.xml index 7676b128f5..53346c0ffc 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ pom com.webank.wedatasphere.dss dss - 0.9.0 + 0.9.1 dss-common @@ -48,7 +48,7 @@ - 0.9.0 + 0.9.1 0.9.4 2.11.8 1.8 diff --git a/qualitis-appjoint/appjoint/pom.xml b/qualitis-appjoint/appjoint/pom.xml index 280e567a85..330b5cfd2f 100644 --- a/qualitis-appjoint/appjoint/pom.xml +++ b/qualitis-appjoint/appjoint/pom.xml @@ -5,7 +5,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/sendemail-appjoint/sendemail-core/pom.xml b/sendemail-appjoint/sendemail-core/pom.xml index 31440bd86c..3739647f0a 100644 --- a/sendemail-appjoint/sendemail-core/pom.xml +++ b/sendemail-appjoint/sendemail-core/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/visualis-appjoint/appjoint/pom.xml b/visualis-appjoint/appjoint/pom.xml index 11506add21..e572638daf 100644 --- a/visualis-appjoint/appjoint/pom.xml +++ b/visualis-appjoint/appjoint/pom.xml @@ -22,7 +22,7 @@ dss com.webank.wedatasphere.dss - 0.9.0 + 0.9.1 4.0.0 diff --git a/web/package.json b/web/package.json index 5ac9b99f5e..f0f6dd8695 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dataspherestudio", - "version": "0.9.0", + "version": "0.9.1", "private": true, "scripts": { "serve": "vue-cli-service serve", From 6b10fc4e894655ce916177ad4d321cebf29778ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B8=E6=B5=B7=E6=B4=8B?= Date: Fri, 19 Feb 2021 14:38:42 +0800 Subject: [PATCH 46/61] Create user to keep user filled content to local --- web/src/js/view/userManager/index.vue | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/web/src/js/view/userManager/index.vue b/web/src/js/view/userManager/index.vue index f25c71ffb8..a56e2f6974 100644 --- a/web/src/js/view/userManager/index.vue +++ b/web/src/js/view/userManager/index.vue @@ -225,8 +225,16 @@ export default { servers: JSON.parse(servers), } } + const dirConfigs = localStorage.getItem('dirConfigs'); + const dirs = dirConfigs ? JSON.parse(dirConfigs) : {}; api.fetch(`/dss/paths`, null, { method: 'get' }).then((rst) => { - this.formCreateUser = { ...this.formCreateUser, ...rst } + const {dssInstallDir, azkakanDir, ...rest} = rst || {}; + this.formCreateUser = { + ...this.formCreateUser, + ...rest, + dssInstallDir: dssInstallDir || dirs.dssInstallDir || "", + azkakanDir: azkakanDir || dirs.azkakanDir || "", + } }) }, methods: { @@ -239,6 +247,13 @@ export default { this.confirmLoading = true this.$refs[name].validate((valid) => { if (valid) { + localStorage.setItem( + 'dirConfigs', + JSON.stringify({ + dssInstallDir: this.formCreateUser.dssInstallDir || "", + azkakanDir: this.formCreateUser.azkakanDir || "" + }) + ) this.$Message.info({ content: this.$t('message.userManager.createTip'), duration: 20 @@ -259,10 +274,6 @@ export default { ) .then((rst) => { this.confirmLoading = false - localStorage.setItem( - 'serverConfigs', - JSON.stringify(this.formCreateUser.servers) - ) if (rst) { this.$Message.success( this.$t('message.userManager.createSuccess') @@ -333,6 +344,11 @@ export default { } + localStorage.setItem( + 'serverConfigs', + JSON.stringify(this.formCreateUser.servers) + ) + this.active = this.active + 1; }else{ From 5a948deaf43efcc9d681295609652820741323d3 Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Tue, 23 Feb 2021 19:25:00 +0800 Subject: [PATCH 47/61] fix builder error --- dss-user-manager/pom.xml | 12 ------------ .../wedatasphpere/dss/user/service/AbsCommand.java | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml index 83d0def7bd..14778cf911 100644 --- a/dss-user-manager/pom.xml +++ b/dss-user-manager/pom.xml @@ -74,23 +74,11 @@ maven-deploy-plugin - - net.alchim31.maven - scala-maven-plugin - org.apache.maven.plugins maven-jar-plugin - - - src/main/java - - **/*.xml - - - \ No newline at end of file diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java index 9c7ce768b2..112224035f 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java @@ -31,7 +31,7 @@ public String renew(AuthorizationBody body) { public String undoAuthorization(AuthorizationBody body) { return Command.SUCCESS; } @Override - public String authorization(AuthorizationBody body) throws IOException,DocumentException { return Command.SUCCESS; } + public String authorization(AuthorizationBody body) throws IOException,DocumentException, Exception { return Command.SUCCESS; } public String toMessage(String msg) { return this.getClass().getSimpleName() + "模块开始执行:"+ msg; } From ef0e83be6bfc52f18e06d5abb902e9d5f82638cb Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Wed, 24 Feb 2021 14:00:52 +0800 Subject: [PATCH 48/61] delete password --- .../src/main/resources/config/properties.conf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 dss-user-manager/src/main/resources/config/properties.conf diff --git a/dss-user-manager/src/main/resources/config/properties.conf b/dss-user-manager/src/main/resources/config/properties.conf new file mode 100644 index 0000000000..ece97f39a3 --- /dev/null +++ b/dss-user-manager/src/main/resources/config/properties.conf @@ -0,0 +1,14 @@ +#--Metastore配置 +base_path = #--元数据位于hdfs位置上的base +metastore_sh = default/Metastore.sh #--执行脚本的位置 +db_tail = #--hdfs上数据库文件的尾缀 +realm = #--kerberos域 +admin = #--获得hive metastore服务admin角色授权的用户(如hdfs,非常重要,否则无法完成授权) + +#--Kerberos配置 +shellFile = default/Kerberos.sh #--执行脚本的位置 +keytabPath = /etc/security/keytabs #--keytab在本节点上的存放位置 +sshPort = 22 #--ssh操作使用的端口 +kdcNode = #--kerberos服务kdc节点 +kdcUser = #--在进行ssh kdc操作是,对应kdc节点上的用户,应当知道该用户的密码,并且该用户应存在于kdc节点sudoers列表内 +password = "password" #--上面提到的kdc接应用户的登录密码,用于ssh操作 From d8eed766ff6b28d8d87786027e99503bb6aa3f6d Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Wed, 24 Feb 2021 15:49:09 +0800 Subject: [PATCH 49/61] clear dss-server password --- .../src/main/resources/linkis.properties | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dss-server/src/main/resources/linkis.properties b/dss-server/src/main/resources/linkis.properties index 79b18225a5..3521e79d32 100644 --- a/dss-server/src/main/resources/linkis.properties +++ b/dss-server/src/main/resources/linkis.properties @@ -17,7 +17,7 @@ wds.linkis.test.mode=true -wds.linkis.server.mybatis.datasource.url=jdbc:mysql://127.0.0.1:3306/ +wds.linkis.server.mybatis.datasource.url=jdbc:mysql://0.0.0.0:3306/dss wds.linkis.server.mybatis.datasource.username= @@ -44,3 +44,22 @@ wds.linkis.gateway.ip=127.0.0.1 wds.linkis.gateway.port=9001 wds.dss.appjoint.scheduler.project.store.dir=file:///appcom/tmp/wds/scheduler +wds.linkis.super.user.name= +wds.linkis.workspace.user.root.path= +wds.linkis.hdfs.user.root.path= +wds.linkis.result.set.root.path= +wds.linkis.scheduler.path= +wds.linkis.user.path=hdfs:///user +wds.linkis.ldap.script.server= +wds.linkis.ldap.script.login.user= +wds.linkis.ldap.script.login.password= +wds.linkis.ldap.script.python.path=/software/tools/bin/ldap_user.py +wds.linkis.ldap.script.source.path=/software/tools/venv/bin/activate +wds.linkis.ldap.script.server.ssh.port=22 +wds.linkis.dss.install.dir=/usr/local/dss_linkis/dss/dss-server +wds.linkis.azkaban.install.dir=/usr/local/dss_linkis/azkban + + +wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LdapCommand + + #,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand From e20b707a198939201a3ef924a9c013f44f83b58d Mon Sep 17 00:00:00 2001 From: "luxl@chinatelecom.cn" Date: Tue, 16 Mar 2021 10:11:38 +0800 Subject: [PATCH 50/61] Optimize account opening script --- .../src/main/resources/linkis.properties | 42 +++++++++++-------- dss-user-manager/pom.xml | 3 ++ .../dss/user/conf/DSSUserManagerConfig.java | 36 +++++++++------- .../dss/user/service/AbsCommand.java | 17 ++++---- .../dss/user/service/Command.java | 10 ++--- .../user/service/impl/KerberosCommand.java | 20 ++++----- .../dss/user/service/impl/LdapCommand.java | 15 +------ .../user/service/impl/MetastoreCommand.java | 25 ++++++----- .../resources/default/CreateLdapAccount.sh | 19 ++------- .../src/main/resources/default/Kerberos.sh | 34 +++++++++++---- .../src/main/resources/default/Metastore.sh | 11 +++-- 11 files changed, 128 insertions(+), 104 deletions(-) diff --git a/dss-server/src/main/resources/linkis.properties b/dss-server/src/main/resources/linkis.properties index 3521e79d32..1d65cc3f9e 100644 --- a/dss-server/src/main/resources/linkis.properties +++ b/dss-server/src/main/resources/linkis.properties @@ -17,7 +17,7 @@ wds.linkis.test.mode=true -wds.linkis.server.mybatis.datasource.url=jdbc:mysql://0.0.0.0:3306/dss +wds.linkis.server.mybatis.datasource.url=jdbc:mysql://0.0.0.1:3306/linkis?characterEncoding=UTF-8 wds.linkis.server.mybatis.datasource.username= @@ -38,28 +38,34 @@ wds.linkis.server.mybatis.typeAliasesPackage=com.webank.wedatasphere.dss.server. wds.linkis.server.mybatis.BasePackage=com.webank.wedatasphere.dss.server.dao,com.webank.wedatasphere.dss.application.dao ##azkaban -wds.dss.appjoint.scheduler.azkaban.address=http://127.0.0.1:8091 +wds.dss.appjoint.scheduler.azkaban.address=http://0.0.0.0:8081 wds.linkis.gateway.ip=127.0.0.1 wds.linkis.gateway.port=9001 wds.dss.appjoint.scheduler.project.store.dir=file:///appcom/tmp/wds/scheduler -wds.linkis.super.user.name= -wds.linkis.workspace.user.root.path= -wds.linkis.hdfs.user.root.path= -wds.linkis.result.set.root.path= -wds.linkis.scheduler.path= +wds.linkis.super.user.name=root +wds.linkis.workspace.user.root.path=file:///tmp/linkis/ +wds.linkis.hdfs.user.root.path=hdfs:///tmp/linkis +wds.linkis.result.set.root.path=hdfs:///tmp/linkis +wds.linkis.scheduler.path=file:///appcom/tmp/wds/scheduler wds.linkis.user.path=hdfs:///user -wds.linkis.ldap.script.server= -wds.linkis.ldap.script.login.user= -wds.linkis.ldap.script.login.password= -wds.linkis.ldap.script.python.path=/software/tools/bin/ldap_user.py -wds.linkis.ldap.script.source.path=/software/tools/venv/bin/activate -wds.linkis.ldap.script.server.ssh.port=22 wds.linkis.dss.install.dir=/usr/local/dss_linkis/dss/dss-server -wds.linkis.azkaban.install.dir=/usr/local/dss_linkis/azkban +wds.linkis.azkaban.install.dir=/usr/local/dss_linkis/azkaban + +wds.linkis.metastore.hive.hdfs.base.path=/user/hive/warehouse +wds.linkis.metastore.script.path=default/Metastore.sh +wds.linkis.metastore.db.tail=_default + +wds.linkis.kerberos.realm= +wds.linkis.kerberos.admin= +wds.linkis.kerberos.enable.switch=0 +wds.linkis.kerberos.script.path=default/Kerberos.sh +wds.linkis.kerberos.keytab.path=/etc/security/keytabs +wds.linkis.kerberos.kdc.node= +wds.linkis.kerberos.kdc.user.name= +wds.linkis.kerberos.kdc.user.password= +wds.linkis.kerberos.ssh.port=22 +wds.dss.deploy.path=/usr/local/dss_linkis +wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LinuxUserCommand,com.webank.wedatasphpere.dss.user.service.impl.LdapCommand,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand - -wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LdapCommand - - #,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand diff --git a/dss-user-manager/pom.xml b/dss-user-manager/pom.xml index 14778cf911..ef03b3a667 100644 --- a/dss-user-manager/pom.xml +++ b/dss-user-manager/pom.xml @@ -11,6 +11,9 @@ dss-user-manager jar + + UTF-8 + diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java index eb98bb715f..3ea45fe05d 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java @@ -13,19 +13,27 @@ public class DSSUserManagerConfig { -// private final static ResourceBundle resource = ResourceBundle.getBundle("linkis"); - public static final String LOCAL_USER_ROOT_PATH = CommonVars.apply("wds.dss.user.root.dir","").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_SERVER = CommonVars.apply("wds.linkis.ldap.script.server", "").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_LOGIN_USER = CommonVars.apply("wds.linkis.ldap.script.login.user", "").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_LOGIN_PASSWORD = CommonVars.apply("wds.linkis.ldap.script.login.password", "").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_PYTHON_PATH = CommonVars.apply("wds.linkis.ldap.script.python.path", "").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_SOURCE_PATH = CommonVars.apply("wds.linkis.ldap.script.source.path", "").getValue(); - public static final String BDP_SERVER_LDAP_SCRIPT_SERVER_SSH_PORT = CommonVars.apply("wds.linkis.ldap.script.server.ssh.port", "22").getValue(); - - public static final String BDP_SERVER_MYBATIS_DATASOURCE_URL = CommonVars.apply("wds.linkis.server.mybatis.datasource.url", "").getValue(); - public static final String BDP_SERVER_MYBATIS_DATASOURCE_USERNAME = CommonVars.apply("wds.linkis.server.mybatis.datasource.username", "").getValue(); - public static final String BDP_SERVER_MYBATIS_DATASOURCE_PASSWORD = CommonVars.apply("wds.linkis.server.mybatis.datasource.password", "").getValue(); - public static final String SCHEDULER_ADDRESS = CommonVars.apply("wds.dss.appjoint.scheduler.azkaban.address", "").getValue(); - public static final String USER_ACCOUNT_COMMANDS = CommonVars.apply("wds.dss.user.account.command.class", "").getValue(); + // private final static ResourceBundle resource = ResourceBundle.getBundle("linkis"); + public static final String LOCAL_USER_ROOT_PATH = CommonVars.apply("wds.dss.user.root.dir","").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_URL = CommonVars.apply("wds.linkis.server.mybatis.datasource.url", "").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_USERNAME = CommonVars.apply("wds.linkis.server.mybatis.datasource.username", "").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_PASSWORD = CommonVars.apply("wds.linkis.server.mybatis.datasource.password", "").getValue().trim(); + public static final String SCHEDULER_ADDRESS = CommonVars.apply("wds.dss.appjoint.scheduler.azkaban.address", "").getValue().trim(); + public static final String USER_ACCOUNT_COMMANDS = CommonVars.apply("wds.dss.user.account.command.class", "").getValue().trim(); + + public static final String METASTORE_HDFS_PATH = CommonVars.apply("wds.linkis.metastore.hive.hdfs.base.path", "").getValue().trim(); + public static final String METASTORE_SCRIPT_PAHT = CommonVars.apply("wds.linkis.metastore.script.path", "").getValue().trim(); + public static final String METASTORE_DB_TAIL = CommonVars.apply("wds.linkis.metastore.db.tail", "_default").getValue().trim(); + + public static final String KERBEROS_REALM = CommonVars.apply("wds.linkis.kerberos.realm", "").getValue().trim(); + public static final String KERBEROS_ADMIN = CommonVars.apply("wds.linkis.kerberos.admin", "").getValue().trim(); + public static final String KERBEROS_SCRIPT_PATH = CommonVars.apply("wds.linkis.kerberos.script.path", "").getValue().trim(); + public static final String KERBEROS_KEYTAB_PATH = CommonVars.apply("wds.linkis.kerberos.keytab.path", "").getValue().trim(); + public static final String KERBEROS_SSH_PORT = CommonVars.apply("wds.linkis.kerberos.ssh.port", "22").getValue().trim(); + public static final String KERBEROS_KDC_NODE = CommonVars.apply("wds.linkis.kerberos.kdc.node", "").getValue().trim(); + public static final String KERBEROS_KDC_USER_NAME = CommonVars.apply("wds.linkis.kerberos.kdc.user.name", "").getValue().trim(); + public static final String KERBEROS_KDC_USER_PASSWORD = CommonVars.apply("wds.linkis.kerberos.kdc.user.password", "").getValue().trim(); + public static final String KEBBEROS_ENABLE_SWITCH = CommonVars.apply("wds.linkis.kerberos.enable.switch", "").getValue().trim(); + public static final String DSS_DEPLOY_PATH = CommonVars.apply("wds.dss.deploy.path", "").getValue().trim(); } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java index 112224035f..70cc82fc65 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java @@ -1,11 +1,13 @@ package com.webank.wedatasphpere.dss.user.service; +import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import org.dom4j.DocumentException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.core.Response; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -31,12 +33,14 @@ public String renew(AuthorizationBody body) { public String undoAuthorization(AuthorizationBody body) { return Command.SUCCESS; } @Override - public String authorization(AuthorizationBody body) throws IOException,DocumentException, Exception { return Command.SUCCESS; } +// public String authorization(AuthorizationBody body) throws DocumentException { return Command.SUCCESS; } + public String authorization(AuthorizationBody body) throws IOException, Exception { return Command.SUCCESS; } + public String toMessage(String msg) { return this.getClass().getSimpleName() + "模块开始执行:"+ msg; } - protected String runShell(String scriptPath, String[] args) throws Exception { + protected String runShell(String scriptPath, String[] args){ String bashCommand; try { bashCommand = "sh " + scriptPath + " " + String.join(" ", args); @@ -51,14 +55,14 @@ protected String runShell(String scriptPath, String[] args) throws Exception { } } - protected String getString(Process process) throws Exception { + protected String getString(Process process) throws IOException, InterruptedException { BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String inline; while ((inline = br.readLine()) != null) { if (!inline.equals("")) { inline = inline.replaceAll("<", "<").replaceAll(">", ">"); - logger.info("shell info:"+inline); + logger.info(inline); } else { logger.info("\n"); } @@ -67,10 +71,9 @@ protected String getString(Process process) throws Exception { br = new BufferedReader(new InputStreamReader(process.getErrorStream())); //错误信息 while ((inline = br.readLine()) != null) { if (!inline.equals("")) - logger.error("shell error:"+inline); + logger.warn(inline); else - logger.error("\n"); -// throw new Exception(inline); + logger.warn("\n"); } int status = process.waitFor(); diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java index d7a15005f7..c1337237e5 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/Command.java @@ -9,33 +9,31 @@ public interface Command { final public static String SUCCESS = "success"; - final public static String ERROR = "create account failed"; - /** * 授权开通服务 * @param body * @return 成功 success 其他失败 */ - public String authorization(AuthorizationBody body) throws Exception; + public String authorization(AuthorizationBody body) throws DocumentException, IOException, Exception; /** * 关闭授权 * @param body * @return 成功 success 其他失败 */ - public String undoAuthorization(AuthorizationBody body) throws Exception; + public String undoAuthorization(AuthorizationBody body); /** * 扩容 * @param body * @return 成功 success 其他失败 */ - public String capacity(AuthorizationBody body) throws Exception; + public String capacity(AuthorizationBody body); /** * 续费 * @param body * @return 成功 success 其他失败 */ - public String renew(AuthorizationBody body) throws Exception; + public String renew(AuthorizationBody body); } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java index c5bd0c9dea..c03394126d 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java @@ -2,6 +2,8 @@ import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; +import com.webank.wedatasphere.linkis.common.conf.CommonVars; +import com.webank.wedatasphpere.dss.user.conf.DSSUserManagerConfig; import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import com.webank.wedatasphpere.dss.user.service.AbsCommand; import com.webank.wedatasphpere.dss.user.service.Command; @@ -17,33 +19,31 @@ public class KerberosCommand extends AbsCommand { @Override public String authorization(AuthorizationBody body) throws Exception { - Config parms = ConfigFactory.load("config/properties.conf"); - String rst = createKt(body, parms); + String rst = createKt(body); return rst != Command.SUCCESS ? rst : Command.SUCCESS; } - private String createKt(AuthorizationBody body, Config parms) throws Exception { - + private String createKt(AuthorizationBody body) throws Exception { String userName = body.getUsername(); String hostName = InetAddress.getLocalHost().getHostName(); String res = null; if(userName != null){ - res = callShell(parms.getString("shellFile"), userName,hostName, - parms.getString("keytabPath"),parms.getString("sshPort"), - parms.getString("kdcNode"),parms.getString("kdcUser"),parms.getString("password"),parms.getString("realm")); + res = callShell(DSSUserManagerConfig.KERBEROS_SCRIPT_PATH, userName,hostName, + DSSUserManagerConfig.KERBEROS_KEYTAB_PATH,DSSUserManagerConfig.KERBEROS_SSH_PORT, + DSSUserManagerConfig.KERBEROS_KDC_NODE,DSSUserManagerConfig.KERBEROS_KDC_USER_NAME,DSSUserManagerConfig.KERBEROS_KDC_USER_PASSWORD,DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KEBBEROS_ENABLE_SWITCH); } return res; } private String callShell(String shellFile, String username, String hostName, String keytabPath, - String sshPort, String kdcNode, String kdcUser,String password, String realm) throws Exception { + String sshPort, String kdcNode, String kdcUser,String password, String realm,String enableSwich) throws Exception { String bashCommand = getResource(shellFile); String scriptCmd ; if(null != hostName){ - scriptCmd = String.format("%s %s %s %s %s %s %s %s", username,hostName,keytabPath,sshPort,kdcNode,kdcUser,password,realm); + scriptCmd = String.format("%s %s %s %s %s %s %s %s %s", username,hostName,keytabPath,sshPort,kdcNode,kdcUser,password,realm,enableSwich); }else { - scriptCmd = String.format("%s %s %s %s %s %s %s", username,keytabPath,sshPort,kdcNode,kdcUser,password,realm); + scriptCmd = String.format("%s %s %s %s %s %s %s %s", username,keytabPath,sshPort,kdcNode,kdcUser,password,realm,enableSwich); } String[] args = scriptCmd.split(" "); return this.runShell(bashCommand, args); diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LdapCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LdapCommand.java index 9dd4ccf835..0773fbcb99 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LdapCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/LdapCommand.java @@ -23,26 +23,15 @@ public class LdapCommand extends AbsCommand { @Override public String authorization(AuthorizationBody body) throws Exception { - - String ldapScriptServer = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_SERVER; - String ldapLoginUser = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_LOGIN_USER; - String ldapLoginPassword = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_LOGIN_PASSWORD; - String ldapPythonPath = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_PYTHON_PATH; - String ldapSourcePath = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_SOURCE_PATH; - String ldapSshPort = DSSUserManagerConfig.BDP_SERVER_LDAP_SCRIPT_SERVER_SSH_PORT; String userName = body.getUsername(); String UserPassword = body.getPassword(); + String dssDeployPath = DSSUserManagerConfig.DSS_DEPLOY_PATH; String bashCommand = this.getClass().getClassLoader().getResource("default/CreateLdapAccount.sh").getPath(); String[] args = { - ldapScriptServer, - ldapLoginUser, - ldapLoginPassword, - ldapPythonPath, - ldapSourcePath, userName, UserPassword, - ldapSshPort, + dssDeployPath }; return this.runShell(bashCommand, args); diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java index 6e17670446..1b2826c879 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java @@ -2,35 +2,38 @@ import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; +import com.webank.wedatasphere.linkis.common.conf.CommonVars; +import com.webank.wedatasphpere.dss.user.conf.DSSUserManagerConfig; import com.webank.wedatasphpere.dss.user.dto.request.AuthorizationBody; import com.webank.wedatasphpere.dss.user.service.AbsCommand; import com.webank.wedatasphpere.dss.user.service.Command; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author anlexander * @date 2021/1/5 */ public class MetastoreCommand extends AbsCommand { + private static final Logger logger = LoggerFactory.getLogger(MetastoreCommand.class); @Override public String authorization(AuthorizationBody body) throws Exception { - Config parms = ConfigFactory.load("config/properties.conf"); - String rst = createDb(body,parms); + String rst = createDb(body); return rst != Command.SUCCESS ? rst : Command.SUCCESS; } - private String createDb(AuthorizationBody body, Config parms) throws Exception { - + private String createDb(AuthorizationBody body) throws Exception { String bashCommand = null; - String scriptCmd = null; + String[] args = null; String userName = body.getUsername(); if (userName != null) { - String dbName = userName + parms.getString("db_tail"); - String path = parms.getString("base_path") + dbName + ".db"; - bashCommand = getResource(parms.getString("metastore_sh")); - scriptCmd = String.format("%s %s %s %s %s %s", userName,dbName,path, - parms.getString("realm"),parms.getString("admin"),parms.getString("keytabPath")); + String dbName = userName + DSSUserManagerConfig.METASTORE_DB_TAIL; + String path = DSSUserManagerConfig.METASTORE_HDFS_PATH + "/"+dbName+".db"; + bashCommand = getResource(DSSUserManagerConfig.METASTORE_SCRIPT_PAHT); + args = new String[]{ userName,dbName,path, + DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KERBEROS_ADMIN,DSSUserManagerConfig.KERBEROS_KEYTAB_PATH,DSSUserManagerConfig.KEBBEROS_ENABLE_SWITCH}; } - return this.runShell(bashCommand, scriptCmd.split(" ")); + return this.runShell(bashCommand, args); } } diff --git a/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh b/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh index 1318ab16b7..0f4c8cbe14 100644 --- a/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh +++ b/dss-user-manager/src/main/resources/default/CreateLdapAccount.sh @@ -1,18 +1,7 @@ #!/bin/bash source /etc/profile -server_host=$1 -server_login_user=$2 -server_login_password=$3 -server_python_path=$4 -server_ldap_source_path=$5 -ldap_user=$6 -ldap_password=$7 -echo "$server_login_password ssh $server_login_user@$server_host sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password" -sshpass -p $server_login_password ssh $server_login_user@$server_host "sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password" -#sshpass -p $server_login_password ssh $server_login_user@$server_host "sudo su - root -c 'source /etc/profile && source $server_ldap_source_path && sudo python $server_python_path add_with_pw $ldap_user -p $ldap_password && deactivate'" - +ldap_user=$1 +ldap_password=$2 +ldap_script_path=$3 +source $ldap_script_path/tools/venv/bin/activate && sudo $ldap_script_path/tools/venv/bin/python $ldap_script_path/tools/bin/ldap_user.py add_with_pw $ldap_user -p $ldap_password echo "******************LDAP USER CREATED***********************" - - - - diff --git a/dss-user-manager/src/main/resources/default/Kerberos.sh b/dss-user-manager/src/main/resources/default/Kerberos.sh index 53bc9541a2..3cd79e5fb0 100644 --- a/dss-user-manager/src/main/resources/default/Kerberos.sh +++ b/dss-user-manager/src/main/resources/default/Kerberos.sh @@ -93,13 +93,13 @@ gen_keytab_user(){ #第一个参数为功能参数(必须有),第二个为user(必须有),第三个为host(可以有) -if [ $# -lt 2 ] || [ $# -gt 8 ]; then +if [ $# -lt 3 ] || [ $# -gt 9 ]; then echo -e "\033[31m \033[05m请确认您的操作,输入格式如下 功能参数 [user|user hostname]\033[0m" echo "Usage: $0 genenateKeytab {username|username hostname}" echo `date '+%Y-%m-%d %H:%M:%S'`" parameters:"$* >>/tmp/deltaKerberos.log exit 1 else - if [ $# -eq 7 ]; then + if [ $# -eq 8 ]; then user=$1 CENTER_KEYTAB_PATH=$2 SSH_PORT=$3 @@ -107,8 +107,20 @@ else KDC_USER=$5 PASSWORD=$6 REALM=$7 - echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user >>/tmp/deltaKerberos.log - gen_keytab_user $user + KERBEROS_ENABLE=$8 + echo $user + echo $CENTER_KEYTAB_PATH + echo $SSH_PORT + echo $KDCSERVER_$KDC_USER + echo $REALM + echo $KERBEROS_ENABLE + if [ $KERBEROS_ENABLE = "0" ]; then + echo "kerberos is disabled" + else + echo "kerberos is enable" + echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user >>/tmp/deltaKerberos.log + gen_keytab_user $user + fi else user=$1 host=$2 @@ -118,8 +130,16 @@ else KDC_USER=$6 PASSWORD=$7 REALM=$8 - echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user" hostname:"$host >>/tmp/deltaKerberos.log - gen_keytab $user $host + KERBEROS_ENABLE=$9 + echo $REALM + echo $KERBEROS_ENABLE + if [ $KERBEROS_ENABLE = "0" ]; then + echo "kerberos is disabled" + else + echo "kerberos1 is enable" + echo `date '+%Y-%m-%d %H:%M:%S'`" in genenate_key_tab username:"$user" hostname:"$host >>/tmp/deltaKerberos.log + gen_keytab $user $host + fi fi fi -exit 0 \ No newline at end of file +exit 0 diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh index e65e3e1ffe..051121240a 100644 --- a/dss-user-manager/src/main/resources/default/Metastore.sh +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -7,9 +7,14 @@ realm=$4 admin=$5 ktPath=$6 host_name=`hostname` - - #一、kerberos认证 -kinit -kt $ktPath/$admin.keytab $admin/${host_name}@${realm} +kerberos_enable=$7 +echo $kerberos_enable +if [ $kerberos_enable = "0" ]; then + echo "kerberos is disabled" +else + echo "kerberos is enabled" + kinit -kt $ktPath/$admin.keytab $admin/${host_name}@${realm} +fi #二、metastore操作 hive -e "create database if not exists $db_name" From 2e94ca3c8b9ddd5fed0835241acc667206b3ed48 Mon Sep 17 00:00:00 2001 From: hantang Date: Thu, 4 Mar 2021 14:16:36 +0800 Subject: [PATCH 51/61] Optimize shell scripts for one click account function --- dss-server/src/main/resources/linkis.properties | 2 +- .../src/main/resources/default/AddschedulerUser.sh | 2 +- .../src/main/resources/default/HdfsPath.sh | 12 +++++++++--- .../src/main/resources/default/Kerberos.sh | 5 +++-- .../src/main/resources/default/LinuxPath.sh | 11 ++++++++--- .../src/main/resources/default/Metastore.sh | 12 ++++++++---- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/dss-server/src/main/resources/linkis.properties b/dss-server/src/main/resources/linkis.properties index 1d65cc3f9e..6d2066895d 100644 --- a/dss-server/src/main/resources/linkis.properties +++ b/dss-server/src/main/resources/linkis.properties @@ -67,5 +67,5 @@ wds.linkis.kerberos.kdc.user.name= wds.linkis.kerberos.kdc.user.password= wds.linkis.kerberos.ssh.port=22 wds.dss.deploy.path=/usr/local/dss_linkis -wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LinuxUserCommand,com.webank.wedatasphpere.dss.user.service.impl.LdapCommand,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand +wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LinuxUserCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.LdapCommand,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand diff --git a/dss-user-manager/src/main/resources/default/AddschedulerUser.sh b/dss-user-manager/src/main/resources/default/AddschedulerUser.sh index ecf4c456b1..d9a5a02e44 100644 --- a/dss-user-manager/src/main/resources/default/AddschedulerUser.sh +++ b/dss-user-manager/src/main/resources/default/AddschedulerUser.sh @@ -15,4 +15,4 @@ if grep -i "^${user}=" $installDir/token.properties; fi else echo "$user=$password" >> $installDir/token.properties -fi \ No newline at end of file +fi diff --git a/dss-user-manager/src/main/resources/default/HdfsPath.sh b/dss-user-manager/src/main/resources/default/HdfsPath.sh index 780f242e34..1f29565014 100644 --- a/dss-user-manager/src/main/resources/default/HdfsPath.sh +++ b/dss-user-manager/src/main/resources/default/HdfsPath.sh @@ -1,7 +1,13 @@ #!/bin/bash - +source /etc/profile user=$1 dir=$2 echo $1 $2 -hdfs dfs -mkdir $dir -hdfs dfs -chown $user:$user $dir \ No newline at end of file +id $user +if [ $? -ne 0 ]; then + sudo useradd $user -s /sbin/nologin + echo "create user successfully" +fi + +hdfs dfs -mkdir -p $dir +hdfs dfs -chown $user:$user $dir diff --git a/dss-user-manager/src/main/resources/default/Kerberos.sh b/dss-user-manager/src/main/resources/default/Kerberos.sh index 3cd79e5fb0..80c3eb502c 100644 --- a/dss-user-manager/src/main/resources/default/Kerberos.sh +++ b/dss-user-manager/src/main/resources/default/Kerberos.sh @@ -1,5 +1,5 @@ #!/bin/bash - +source /etc/profile #需要将当前登录用户,如dss加入到sudoers #函数 @@ -62,7 +62,8 @@ gen_keytab(){ generate_user $user sudo chown $user $CENTER_KEYTAB_PATH/$user.keytab sudo su - $user -c "kinit -kt $CENTER_KEYTAB_PATH/$user.keytab $principal" - sudo su - op -c "crontab -l > conf && echo '* */12 * * * sudo -u $user kinit -kt $CENTER_KEYTAB_PATH/$user.keytab $principal' >> conf && crontab conf && rm -f conf" + deployUser=`whoami` + sudo su - $deployUser -c "crontab -l > conf && echo '* */12 * * * sudo -u $user kinit -kt $CENTER_KEYTAB_PATH/$user.keytab $principal' >> conf && crontab conf && rm -f conf" fi else echo "the $user.keytab does not exist, please check your previous steps!" diff --git a/dss-user-manager/src/main/resources/default/LinuxPath.sh b/dss-user-manager/src/main/resources/default/LinuxPath.sh index 85e1a73aa4..03db38d857 100644 --- a/dss-user-manager/src/main/resources/default/LinuxPath.sh +++ b/dss-user-manager/src/main/resources/default/LinuxPath.sh @@ -1,7 +1,12 @@ #!/bin/bash - +source /etc/profile user=$1 dir=$2 echo $1 $2; -sudo mkdir $dir -sudo chown $user:$user $dir \ No newline at end of file +id $user +if [ $? -ne 0 ]; then + useradd $user -s /sbin/nologin + echo "create user successfully" +fi +sudo mkdir -p $dir +sudo chown $user:$user $dir diff --git a/dss-user-manager/src/main/resources/default/Metastore.sh b/dss-user-manager/src/main/resources/default/Metastore.sh index 051121240a..3d72f66589 100644 --- a/dss-user-manager/src/main/resources/default/Metastore.sh +++ b/dss-user-manager/src/main/resources/default/Metastore.sh @@ -1,5 +1,5 @@ #!/bin/bash - +source /etc/profile user_name=$1 db_name=$2 path=$3 @@ -22,16 +22,20 @@ if [[ $? -ne 0 ]]; then echo "create database failed!" else #修改数据库所属,将principal用户添加到metastore侧hive-site.xml hive.users.in.admin.role中 - hive -e "set role admin ; grant all on database $db_name to user $user_name" - echo "grant database $db_name successfully!" + if [ $kerberos_enable = "0" ]; then + hive -e "grant all on database $db_name to user $user_name" + else + hive -e "set role admin; grant all on database $db_name to user $user_name" + fi fi #三、hdfs操作 if [[ $? -ne 0 ]]; then #回滚 hive -e "drop database $db_name" - echo "rollback finished!" + echo "grant database failed,rollback finished!" else + echo "grant database $db_name successfully!" #修改hdfs路径所属 hdfs dfs -chown $user_name:$user_name $path #修改hdfs路径权限 From 64ef8b10353b132f948a2068c493633a392f5fec Mon Sep 17 00:00:00 2001 From: hantang Date: Thu, 4 Mar 2021 14:20:14 +0800 Subject: [PATCH 52/61] modify file the DSSUserManagerConfig file --- .../dss/user/conf/DSSUserManagerConfig.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java index 3ea45fe05d..f6e46202eb 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java @@ -13,27 +13,27 @@ public class DSSUserManagerConfig { - // private final static ResourceBundle resource = ResourceBundle.getBundle("linkis"); - public static final String LOCAL_USER_ROOT_PATH = CommonVars.apply("wds.dss.user.root.dir","").getValue().trim(); - public static final String BDP_SERVER_MYBATIS_DATASOURCE_URL = CommonVars.apply("wds.linkis.server.mybatis.datasource.url", "").getValue().trim(); - public static final String BDP_SERVER_MYBATIS_DATASOURCE_USERNAME = CommonVars.apply("wds.linkis.server.mybatis.datasource.username", "").getValue().trim(); - public static final String BDP_SERVER_MYBATIS_DATASOURCE_PASSWORD = CommonVars.apply("wds.linkis.server.mybatis.datasource.password", "").getValue().trim(); - public static final String SCHEDULER_ADDRESS = CommonVars.apply("wds.dss.appjoint.scheduler.azkaban.address", "").getValue().trim(); - public static final String USER_ACCOUNT_COMMANDS = CommonVars.apply("wds.dss.user.account.command.class", "").getValue().trim(); - - public static final String METASTORE_HDFS_PATH = CommonVars.apply("wds.linkis.metastore.hive.hdfs.base.path", "").getValue().trim(); - public static final String METASTORE_SCRIPT_PAHT = CommonVars.apply("wds.linkis.metastore.script.path", "").getValue().trim(); +// private final static ResourceBundle resource = ResourceBundle.getBundle("linkis"); + public static final String LOCAL_USER_ROOT_PATH = CommonVars.apply("wds.dss.user.root.dir","null").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_URL = CommonVars.apply("wds.linkis.server.mybatis.datasource.url", "null").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_USERNAME = CommonVars.apply("wds.linkis.server.mybatis.datasource.username", "null").getValue().trim(); + public static final String BDP_SERVER_MYBATIS_DATASOURCE_PASSWORD = CommonVars.apply("wds.linkis.server.mybatis.datasource.password", "null").getValue().trim(); + public static final String SCHEDULER_ADDRESS = CommonVars.apply("wds.dss.appjoint.scheduler.azkaban.address", "null").getValue().trim(); + public static final String USER_ACCOUNT_COMMANDS = CommonVars.apply("wds.dss.user.account.command.class", "null").getValue().trim(); + + public static final String METASTORE_HDFS_PATH = CommonVars.apply("wds.linkis.metastore.hive.hdfs.base.path", "null").getValue().trim(); + public static final String METASTORE_SCRIPT_PAHT = CommonVars.apply("wds.linkis.metastore.script.path", "null").getValue().trim(); public static final String METASTORE_DB_TAIL = CommonVars.apply("wds.linkis.metastore.db.tail", "_default").getValue().trim(); - public static final String KERBEROS_REALM = CommonVars.apply("wds.linkis.kerberos.realm", "").getValue().trim(); - public static final String KERBEROS_ADMIN = CommonVars.apply("wds.linkis.kerberos.admin", "").getValue().trim(); - public static final String KERBEROS_SCRIPT_PATH = CommonVars.apply("wds.linkis.kerberos.script.path", "").getValue().trim(); - public static final String KERBEROS_KEYTAB_PATH = CommonVars.apply("wds.linkis.kerberos.keytab.path", "").getValue().trim(); + public static final String KERBEROS_REALM = CommonVars.apply("wds.linkis.kerberos.realm", "null").getValue().trim(); + public static final String KERBEROS_ADMIN = CommonVars.apply("wds.linkis.kerberos.admin", "null").getValue().trim(); + public static final String KERBEROS_SCRIPT_PATH = CommonVars.apply("wds.linkis.kerberos.script.path", "null").getValue().trim(); + public static final String KERBEROS_KEYTAB_PATH = CommonVars.apply("wds.linkis.kerberos.keytab.path", "null").getValue().trim(); public static final String KERBEROS_SSH_PORT = CommonVars.apply("wds.linkis.kerberos.ssh.port", "22").getValue().trim(); - public static final String KERBEROS_KDC_NODE = CommonVars.apply("wds.linkis.kerberos.kdc.node", "").getValue().trim(); - public static final String KERBEROS_KDC_USER_NAME = CommonVars.apply("wds.linkis.kerberos.kdc.user.name", "").getValue().trim(); - public static final String KERBEROS_KDC_USER_PASSWORD = CommonVars.apply("wds.linkis.kerberos.kdc.user.password", "").getValue().trim(); - public static final String KEBBEROS_ENABLE_SWITCH = CommonVars.apply("wds.linkis.kerberos.enable.switch", "").getValue().trim(); - public static final String DSS_DEPLOY_PATH = CommonVars.apply("wds.dss.deploy.path", "").getValue().trim(); + public static final String KERBEROS_KDC_NODE = CommonVars.apply("wds.linkis.kerberos.kdc.node", "null").getValue().trim(); + public static final String KERBEROS_KDC_USER_NAME = CommonVars.apply("wds.linkis.kerberos.kdc.user.name", "null").getValue().trim(); + public static final String KERBEROS_KDC_USER_PASSWORD = CommonVars.apply("wds.linkis.kerberos.kdc.user.password", "null").getValue().trim(); + public static final String KEBBEROS_ENABLE_SWITCH = CommonVars.apply("wds.linkis.kerberos.enable.switch", "null").getValue().trim(); + public static final String DSS_DEPLOY_PATH = CommonVars.apply("wds.dss.deploy.path", "null").getValue().trim(); } From b4f10c3949ba93c4fc031557f19fa4265871aadd Mon Sep 17 00:00:00 2001 From: hantang Date: Fri, 5 Mar 2021 10:47:09 +0800 Subject: [PATCH 53/61] add notes in English --- .../dss/server/constant/DSSServerConstant.java | 4 ++-- dss-server/src/main/resources/linkis.properties | 2 +- .../dss/user/conf/DSSUserManagerConfig.java | 5 ++++- .../wedatasphpere/dss/user/service/AbsCommand.java | 2 +- .../dss/user/service/impl/KerberosCommand.java | 2 +- .../dss/user/service/impl/MetastoreCommand.java | 10 +++++----- .../dss/user/service/impl/SchedulisCommand.java | 3 ++- .../src/main/resources/default/CreateLinuxUser.sh | 9 ++++----- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/dss-server/src/main/java/com/webank/wedatasphere/dss/server/constant/DSSServerConstant.java b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/constant/DSSServerConstant.java index 0e2a92e2ee..2c5711e154 100644 --- a/dss-server/src/main/java/com/webank/wedatasphere/dss/server/constant/DSSServerConstant.java +++ b/dss-server/src/main/java/com/webank/wedatasphere/dss/server/constant/DSSServerConstant.java @@ -24,10 +24,10 @@ public class DSSServerConstant { public static final String DSS_PROJECT_SOURCE = "create by user"; public static final String DSS_WORKSPACE_SOURCE = "create by user"; public static final String PROJECT_VERSION_ID = "projectVersionID"; - public static final String PUBLISH_FLOW_REPORT_FORMATE = "工作流名:%s,版本号:%s,工作流内容为空,请自行修改或者删除"; + public static final String PUBLISH_FLOW_REPORT_FORMATE = "the workflow name is% s, the version number is% s, and the workflow content is empty. Please modify or delete it by yourself"; public static final String EMVEDDEDFLOWID = "\"embeddedFlowId\":"; public static final String VERSION_FORMAT = "%06d"; public static final String VERSION_PREFIX = "v"; - public static final String SUPER_USER_LOGIN_ERROR = "没有创建权限,请使用超级用户登录"; + public static final String SUPER_USER_LOGIN_ERROR = "please login with super user"; } diff --git a/dss-server/src/main/resources/linkis.properties b/dss-server/src/main/resources/linkis.properties index 6d2066895d..29d756063c 100644 --- a/dss-server/src/main/resources/linkis.properties +++ b/dss-server/src/main/resources/linkis.properties @@ -68,4 +68,4 @@ wds.linkis.kerberos.kdc.user.password= wds.linkis.kerberos.ssh.port=22 wds.dss.deploy.path=/usr/local/dss_linkis wds.dss.user.account.command.class=com.webank.wedatasphpere.dss.user.service.impl.LinuxUserCommand,com.webank.wedatasphpere.dss.user.service.impl.KerberosCommand,com.webank.wedatasphpere.dss.user.service.impl.LdapCommand,com.webank.wedatasphpere.dss.user.service.impl.WorkspaceCommand,com.webank.wedatasphpere.dss.user.service.impl.MetastoreCommand,com.webank.wedatasphpere.dss.user.service.impl.AzkabanCommand - +wds.dss.scheduler.url=/luban/schedule/system \ No newline at end of file diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java index f6e46202eb..6a014119da 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/conf/DSSUserManagerConfig.java @@ -33,7 +33,10 @@ public class DSSUserManagerConfig { public static final String KERBEROS_KDC_NODE = CommonVars.apply("wds.linkis.kerberos.kdc.node", "null").getValue().trim(); public static final String KERBEROS_KDC_USER_NAME = CommonVars.apply("wds.linkis.kerberos.kdc.user.name", "null").getValue().trim(); public static final String KERBEROS_KDC_USER_PASSWORD = CommonVars.apply("wds.linkis.kerberos.kdc.user.password", "null").getValue().trim(); - public static final String KEBBEROS_ENABLE_SWITCH = CommonVars.apply("wds.linkis.kerberos.enable.switch", "null").getValue().trim(); + public static final String KERBEROS_ENABLE_SWITCH = CommonVars.apply("wds.linkis.kerberos.enable.switch", "null").getValue().trim(); public static final String DSS_DEPLOY_PATH = CommonVars.apply("wds.dss.deploy.path", "null").getValue().trim(); + public static final String DSS_SCHEDULER_URL = CommonVars.apply("wds.dss.scheduler.url", "/luban/schedule/system").getValue().trim(); + + } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java index 70cc82fc65..ec7f443113 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/AbsCommand.java @@ -37,7 +37,7 @@ public String renew(AuthorizationBody body) { public String authorization(AuthorizationBody body) throws IOException, Exception { return Command.SUCCESS; } public String toMessage(String msg) { - return this.getClass().getSimpleName() + "模块开始执行:"+ msg; + return this.getClass().getSimpleName() + "the module starts execution"+ msg; } protected String runShell(String scriptPath, String[] args){ diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java index c03394126d..10f77b503c 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/KerberosCommand.java @@ -30,7 +30,7 @@ private String createKt(AuthorizationBody body) throws Exception { if(userName != null){ res = callShell(DSSUserManagerConfig.KERBEROS_SCRIPT_PATH, userName,hostName, DSSUserManagerConfig.KERBEROS_KEYTAB_PATH,DSSUserManagerConfig.KERBEROS_SSH_PORT, - DSSUserManagerConfig.KERBEROS_KDC_NODE,DSSUserManagerConfig.KERBEROS_KDC_USER_NAME,DSSUserManagerConfig.KERBEROS_KDC_USER_PASSWORD,DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KEBBEROS_ENABLE_SWITCH); + DSSUserManagerConfig.KERBEROS_KDC_NODE,DSSUserManagerConfig.KERBEROS_KDC_USER_NAME,DSSUserManagerConfig.KERBEROS_KDC_USER_PASSWORD,DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KERBEROS_ENABLE_SWITCH); } return res; } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java index 1b2826c879..383aa35f32 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/MetastoreCommand.java @@ -28,11 +28,11 @@ private String createDb(AuthorizationBody body) throws Exception { String[] args = null; String userName = body.getUsername(); if (userName != null) { - String dbName = userName + DSSUserManagerConfig.METASTORE_DB_TAIL; - String path = DSSUserManagerConfig.METASTORE_HDFS_PATH + "/"+dbName+".db"; - bashCommand = getResource(DSSUserManagerConfig.METASTORE_SCRIPT_PAHT); - args = new String[]{ userName,dbName,path, - DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KERBEROS_ADMIN,DSSUserManagerConfig.KERBEROS_KEYTAB_PATH,DSSUserManagerConfig.KEBBEROS_ENABLE_SWITCH}; + String dbName = userName + DSSUserManagerConfig.METASTORE_DB_TAIL; + String path = DSSUserManagerConfig.METASTORE_HDFS_PATH + "/"+dbName+".db"; + bashCommand = getResource(DSSUserManagerConfig.METASTORE_SCRIPT_PAHT); + args = new String[]{ userName,dbName,path, + DSSUserManagerConfig.KERBEROS_REALM,DSSUserManagerConfig.KERBEROS_ADMIN,DSSUserManagerConfig.KERBEROS_KEYTAB_PATH,DSSUserManagerConfig.KERBEROS_ENABLE_SWITCH}; } return this.runShell(bashCommand, args); } diff --git a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/SchedulisCommand.java b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/SchedulisCommand.java index 9a86d3cffa..002ce0b098 100644 --- a/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/SchedulisCommand.java +++ b/dss-user-manager/src/main/java/com/webank/wedatasphpere/dss/user/service/impl/SchedulisCommand.java @@ -83,10 +83,11 @@ private static Connection getConnection() { } private boolean addSchedulisUser(String username, String password) { + String schedulerUrl = DSSUserManagerConfig.DSS_SCHEDULER_URL; RestTemplate restTemplate = new RestTemplate(); String schedulisUrl = DSSUserManagerConfig.SCHEDULER_ADDRESS; String url = new StringBuilder().append(schedulisUrl) - .append("/luban/schedule/system") + .append(schedulerUrl) .toString(); Map params = new HashMap<>(4); params.put("userId", username); diff --git a/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh b/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh index fabcac1c5a..32e42bccc0 100644 --- a/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh +++ b/dss-user-manager/src/main/resources/default/CreateLinuxUser.sh @@ -15,10 +15,10 @@ do echo "${server_host},${server_user_name},${server_user_password}" sudo sshpass -p $server_user_password ssh -o ConnectTimeout=1 $server_user_name@$server_host "echo success" - [ $? -ne 0 ] && echo "登录主机${server_host}失败" && exit 254 + [ $? -ne 0 ] && echo "logon server:${server_host} failed" && exit 254 done -echo "************服务器网络校验通过,开始创建用户*****************" +echo "************Start creating user*****************" for server_user_str in ${server_user_array[@]} do @@ -27,9 +27,8 @@ do server_host=${server_user_info[0]} server_user_name=${server_user_info[1]} server_user_password=${server_user_info[2]} - #sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name && echo $add_user_password |sudo -i passwd --stdin $add_user_name" - sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name -s /sbin/nologin" + sshpass -p $server_user_password ssh $server_user_name@$server_host "sudo useradd $add_user_name -s /sbin/nologin" - [ $? -ne 0 ] && echo "创建用户失败:${host}失败" && exit 254 + [ $? -ne 0 ] && echo "create user failed:${host}" && exit 254 done From 26c444eb17462a293e95019caa10633fdf21b41b Mon Sep 17 00:00:00 2001 From: luxiaolong Date: Fri, 5 Mar 2021 09:27:12 +0800 Subject: [PATCH 54/61] better data type --- .../wedatasphere/dss/application/entity/DSSUser.java | 7 +++---- .../dss/application/restful/ApplicationRestfulApi.java | 5 ++--- web/src/js/module/header/userMenu.vue | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java index 655257aea2..73dd36aca0 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/entity/DSSUser.java @@ -25,13 +25,12 @@ public class DSSUser { private String username; private String name; private Boolean isFirstLogin; - //增加是否超级用户表示 0-不是超级用户 1-是超级用户 - private int isSuperUser = 0; + private boolean isSuperUser = false; - public int getIsSuperUser() { + public boolean getIsSuperUser() { return isSuperUser; } - public void setIsSuperUser(int isSuperUser) { + public void setIsSuperUser(boolean isSuperUser) { this.isSuperUser = isSuperUser; } diff --git a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java index 628f8aa1f7..10552b25f2 100644 --- a/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java +++ b/dss-application/src/main/java/com/webank/wedatasphere/dss/application/restful/ApplicationRestfulApi.java @@ -75,11 +75,10 @@ public Response getBaseInfo(@Context HttpServletRequest req){ DSSUser dssUser = dataworkisUserService.getUserByName(username); DSSUserVO dataworkisUserVO = new DSSUserVO(); String superUserName = ApplicationConf.SUPER_USER_NAME; - //是否超级用户登录 if(username.equals(superUserName)){ - dssUser.setIsSuperUser(1); + dssUser.setIsSuperUser(true); }else{ - dssUser.setIsSuperUser(0); + dssUser.setIsSuperUser(false); } dataworkisUserVO.setBasic(dssUser); diff --git a/web/src/js/module/header/userMenu.vue b/web/src/js/module/header/userMenu.vue index f71b290de1..47c26f7a3e 100644 --- a/web/src/js/module/header/userMenu.vue +++ b/web/src/js/module/header/userMenu.vue @@ -17,11 +17,10 @@