فهرست منبع

Merge branch 'feature/invoke_power' into 'wrdp'

服务调用的鉴权功能

See merge request o2oa/o2oa!2814
胡起 5 سال پیش
والد
کامیت
43f97be3d8

+ 2 - 2
gulpfile.js

@@ -941,8 +941,8 @@ exports.build_web = gulp.series(
         build_bundle
     ),
     build_web_v_html,
-    gulp.series(build_doc, build_web_api),
-    build_web_v_o2);
+    build_web_v_o2,
+    gulp.series(build_doc, build_web_api));
 
 if (os.platform().indexOf("win")==-1){
     exports.deploy = gulp.series(deploy_server, chmod_jvm, chmod_commons, chmod_sh, chmod_servers);

+ 1 - 0
o2web/source/o2_core/o2/xAction/services/x_program_center.json

@@ -89,6 +89,7 @@
   "deleteInvoke" : {"uri": "/jaxrs/invoke/{flag}", "method": "DELETE"},
   "getInvoke" : {"uri": "/jaxrs/invoke/{flag}"},
   "executeInvoke" : {"uri": "/jaxrs/invoke/{flag}/execute", "method": "POST"},
+  "executeToken" : {"uri": "/jaxrs/invoke/{flag}/client/{client}/token/{token}/execute", "method": "POST"},
 
   "listPromptErrorLog" : {"uri": "/jaxrs/prompterrorlog/list/{id}/next/{count}"},
   "listPromptErrorLogWithDate" : {"uri": "/jaxrs/prompterrorlog/list/{id}/next/{count}/date/{date}"},

+ 6 - 6
o2web/source/x_component_Setting/lp/zh-cn.js

@@ -95,11 +95,11 @@ MWF.xApplication.Setting.LP = {
     "base_indexPortalId_infor": "选择系统首页的门户。(重启服务器后生效)",
 
 
-    "base_ssoSetting": "配置与其它系统的单点登录设置",
-    "base_ssos": "SSO配置",
-    "base_sso_infor": "您可以为多个系统创建SSO配置",
-    "base_sso_action": "添加SSO配置",
-    "base_sso_editAction": "编辑SSO配置",
+    "base_ssoSetting": "配置与其它系统的鉴权和单点登录设置",
+    "base_ssos": "鉴权配置",
+    "base_sso_infor": "您可以为多个系统创建鉴权,用于SSO登录和服务调用",
+    "base_sso_action": "添加鉴权配置",
+    "base_sso_editAction": "编辑鉴权配置",
 
     "base_oauths": "OAUTH客户端配置",
     "base_oauths_infor": "如果本系统作为OAUTH2认证服务器,您可以在此可以配置多个OAUTH客户端,为其他系统实现授权",
@@ -241,7 +241,7 @@ MWF.xApplication.Setting.LP = {
 
     "pleaseInput": "请输入",
     "list": {
-        "client": "SSO名称",
+        "client": "鉴权名称",
         "key": "密钥(最少8位)",
         "clientId": "客户号(ClientId)",
         "mapping": "映射 (Mapping)",

+ 1 - 1
o2web/source/x_component_process_Xform/Org.js

@@ -1212,7 +1212,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class(
             }
         }.bind(this), function(){});
 
-        this.moduleValueAG = Promise.resolve(p);
+        this.moduleValueAG = p;
         if (p && p.then) p.then(function(){
             this.moduleValueAG = null;
         }.bind(this), function(){

+ 43 - 10
o2web/source/x_component_service_InvokeDesigner/Invoke.js

@@ -217,6 +217,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
         this.designer.propertyNameNode.set("value", this.data.name || "");
         this.designer.propertyAliasNode.set("value", this.data.alias || "");
 
+        this.designer.propertyEnableTokenNode.getElement("option[value='"+ this.data.enableToken +"']").set("selected", true );
         this.designer.propertyEnableNode.getElement("option[value='"+ this.data.enable +"']").set("selected", true );
 
         this.designer.propertyRemoteAddrRegexNode.set("value", this.data.remoteAddrRegex || "");
@@ -226,11 +227,31 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
 
         this.designer.propertyDescriptionNode.set("value", this.data.description || "");
 
+        this.setInvokeUrlText();
+        this.designer.propertyEnableTokenNode.addEvent("change", this.setInvokeUrlText.bind(this));
+    },
+    setInvokeUrlText: function(){
+        debugger
         var action = this.designer.actions.action;
-        var uri = action.address + action.actions.executeInvoke.uri ;
-        uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
+        var url;
+
+        var enableToken = true;
+        this.designer.propertyEnableTokenNode.getElements("option").each( function(option){
+            if( option.selected ){
+                enableToken =  (option.value == "true");
+            }
+        });
+
+        if (enableToken===true){
+            uri = action.address + action.actions.executeToken.uri ;
+            uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
+        }else{
+            var uri = action.address + action.actions.executeInvoke.uri ;
+            uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
+        }
         this.designer.propertyInvokeUriNode.set("text", uri);
     },
+
     setAreaNodeSize: function(){
         var size = this.node.getSize();
         var tabSize = this.tab.tabNodeContainer.getSize();
@@ -275,6 +296,14 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
                 }
             });
 
+            var enableToken = true;
+            this.designer.propertyEnableTokenNode.getElements("option").each( function(option){
+                if( option.selected ){
+                    enableToken =  (option.value == "true");
+                }
+            });
+
+
             if (!name){
                 this.designer.notice(this.designer.lp.notice.inputName, "error");
                 return false;
@@ -290,6 +319,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
             this.data.validated = validated;
             this.data.text = this.editor.editor.getValue();
             this.data.enable = enable;
+            this.data.enableToken = enableToken;
 
             this.isSave = true;
             this.saveInvoke(this.data, function(json){
@@ -307,10 +337,12 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
                 this.data.id = json.data.id;
                 this.designer.propertyIdNode.set("text", this.data.id );
 
-                var action = this.designer.actions.action;
-                var uri = action.address + action.actions.executeInvoke.uri ;
-                uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
-                this.designer.propertyInvokeUriNode.set("text", uri);
+
+                this.setInvokeUrlText()
+                // var action = this.designer.actions.action;
+                // var uri = action.address + action.actions.executeInvoke.uri ;
+                // uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
+                // this.designer.propertyInvokeUriNode.set("text", uri);
 
                 if (callback) callback();
             }.bind(this), function(xhr, text, error){
@@ -385,10 +417,11 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
                 if( this.designer.currentScript == this ){
                     this.designer.propertyIdNode.set("text", this.data.id );
 
-                    var action = this.designer.actions.action;
-                    var uri = action.address + action.actions.executeInvoke.uri ;
-                    uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
-                    this.designer.propertyInvokeUriNode.set("text", uri);
+                    this.setInvokeUrlText();
+                    // var action = this.designer.actions.action;
+                    // var uri = action.address + action.actions.executeInvoke.uri ;
+                    // uri = uri.replace("{flag}", this.data.alias || this.data.name || this.data.id );
+                    // this.designer.propertyInvokeUriNode.set("text", uri);
                 }
 
                 if (callback) callback();

+ 13 - 0
o2web/source/x_component_service_InvokeDesigner/Main.js

@@ -582,6 +582,18 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({
         node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.description+":"}).inject(this.propertyContentArea);
         this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode, "value": ""}).inject(this.propertyContentArea);
 
+        node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.enableToken+":"}).inject(this.propertyContentArea);
+        this.propertyEnableTokenNode = new Element("select", {"styles": this.css.propertySelectNode }).inject(this.propertyContentArea);
+        new Element("option" , {  "value" : "true", "text" : this.lp.true  }).inject(this.propertyEnableTokenNode);
+        new Element("option" , {  "value" : "false", "text" : this.lp.false  }).inject(this.propertyEnableTokenNode);
+        new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.enableTokenInfo}).setStyles({
+            "word-break":"break-all",
+            "height" : "auto",
+            "line-height": "18px",
+            "margin-top": "10px",
+            "color": "#999999"
+        }).inject(this.propertyContentArea);
+
         node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.isEnable+":"}).inject(this.propertyContentArea);
         this.propertyEnableNode = new Element("select", {"styles": this.css.propertySelectNode }).inject(this.propertyContentArea);
         new Element("option" , {  "value" : "true", "text" : this.lp.true  }).inject(this.propertyEnableNode);
@@ -774,6 +786,7 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({
                 //"dependInvokeList": [],
                 "isNewInvoke": true,
                 "text": "",
+                "enableToken" : true,
                 "enable" : true,
                 "remoteAddrRegex" : "",
                 "lastStartTime" : "",

+ 3 - 1
o2web/source/x_component_service_InvokeDesigner/lp/zh-cn.js

@@ -20,6 +20,8 @@ MWF.xApplication.service.InvokeDesigner.LP = {
         "disable" : "点击禁用",
         "invokeUri" : "调用地址",
         "invokeMethod" : "调用方法",
+        "enableToken": "启用鉴权",
+        "enableTokenInfo": "启用鉴权后,您必须使用鉴权客户端名称和加密后的token来调用服务",
 
 		"notice": {
 			"save_success": "接口保存成功!",
@@ -39,4 +41,4 @@ MWF.xApplication.service.InvokeDesigner.LP = {
             "inputName": "请输入接口名称",
             "inputCron" : "定时任务corn表达式不能为空"
 		}
-};
+};