From f0f33f4a91f1f40ca1c0eabf4ee385b8b00484aa Mon Sep 17 00:00:00 2001 From: Doflatango Date: Thu, 9 Mar 2017 14:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf.go | 6 +++--- conf/files/security.json.sample | 6 +++--- web/configuration.go | 17 ++--------------- web/ui/src/components/JobEdit.vue | 10 +++++----- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/conf/conf.go b/conf/conf.go index f622fc7..f771c8b 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -73,11 +73,11 @@ type Security struct { // 所执行的命令只能是机器上的脚本,仅支持配置项里的扩展名 // 执行用户只能选择配置里的用户 // false 关闭,命令和用户可以用动填写 - Open bool + Open bool `json:"open"` // 配置执行用户 - Users []string + Users []string `json:"users"` // 支持的执行的脚本扩展名 - Ext []string + Ext []string `json:"ext"` } // 返回前后包含斜杆的 /a/b/ 的前缀 diff --git a/conf/files/security.json.sample b/conf/files/security.json.sample index 111e736..e33d63d 100644 --- a/conf/files/security.json.sample +++ b/conf/files/security.json.sample @@ -1,9 +1,9 @@ { - "Open": false, - "Users": [ + "open": false, + "users": [ "www", "db" ], - "Ext": [ + "ext": [ ".sh", ".py" ] } \ No newline at end of file diff --git a/web/configuration.go b/web/configuration.go index 2a349e3..4119939 100644 --- a/web/configuration.go +++ b/web/configuration.go @@ -7,25 +7,12 @@ import ( ) type Configuration struct { - Security *securityCnf `json:"security"` -} - -type securityCnf struct { - Enable bool `json:"enable"` - AllowUsers []string `json:"allowUsers,omitempty"` - AllowSuffixs []string `json:"allowSuffixs,omitempty"` + Security *conf.Security `json:"security"` } func NewConfiguration() *Configuration { cnf := &Configuration{ - Security: &securityCnf{ - Enable: conf.Config.Security.Open, - }, - } - - if conf.Config.Security.Open { - cnf.Security.AllowUsers = conf.Config.Security.Users - cnf.Security.AllowSuffixs = conf.Config.Security.Ext + Security: conf.Config.Security, } return cnf diff --git a/web/ui/src/components/JobEdit.vue b/web/ui/src/components/JobEdit.vue index 1e4f714..1d0134b 100644 --- a/web/ui/src/components/JobEdit.vue +++ b/web/ui/src/components/JobEdit.vue @@ -26,8 +26,8 @@
- - + +
@@ -136,9 +136,9 @@ export default { mounted: function(){ var vm = this; var secCnf = this.$appConfig.security; - if (secCnf.enable) { - if (secCnf.allowSuffixs && secCnf.allowSuffixs.length > 0) { - this.allowSuffixsTip = '(当前限制只允许添加此类后缀脚本:' + secCnf.allowSuffixs.join(' ') + ')'; + if (secCnf.open) { + if (secCnf.ext && secCnf.ext.length > 0) { + this.allowSuffixsTip = '(当前限制只允许添加此类后缀脚本:' + secCnf.ext.join(' ') + ')'; } }