mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 11:20:27 +08:00
WAF人机识别实现点击验证和滑动解锁验证/单个网站可以设置默认的人机识别方式
This commit is contained in:
@@ -63,7 +63,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_COND_COMPONENTS = ")
|
buffer.WriteString("window.REQUEST_COND_COMPONENTS = ")
|
||||||
buffer.Write(typesJSON)
|
buffer.Write(typesJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 条件操作符
|
// 条件操作符
|
||||||
@@ -73,7 +73,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_COND_OPERATORS = ")
|
buffer.WriteString("window.REQUEST_COND_OPERATORS = ")
|
||||||
buffer.Write(requestOperatorsJSON)
|
buffer.Write(requestOperatorsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求变量
|
// 请求变量
|
||||||
@@ -83,7 +83,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_VARIABLES = ")
|
buffer.WriteString("window.REQUEST_VARIABLES = ")
|
||||||
buffer.Write(requestVariablesJSON)
|
buffer.Write(requestVariablesJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指标
|
// 指标
|
||||||
@@ -93,7 +93,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.METRIC_HTTP_KEYS = ")
|
buffer.WriteString("window.METRIC_HTTP_KEYS = ")
|
||||||
buffer.Write(metricHTTPKeysJSON)
|
buffer.Write(metricHTTPKeysJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP地址阈值项目
|
// IP地址阈值项目
|
||||||
@@ -103,7 +103,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ")
|
buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ")
|
||||||
buffer.Write(ipAddrThresholdItemsJSON)
|
buffer.Write(ipAddrThresholdItemsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP地址阈值动作
|
// IP地址阈值动作
|
||||||
@@ -113,7 +113,7 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.IP_ADDR_THRESHOLD_ACTIONS = ")
|
buffer.WriteString("window.IP_ADDR_THRESHOLD_ACTIONS = ")
|
||||||
buffer.Write(ipAddrThresholdActionsJSON)
|
buffer.Write(ipAddrThresholdActionsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// WAF操作符
|
// WAF操作符
|
||||||
@@ -123,7 +123,17 @@ func generateComponentsJSFile() error {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.WAF_RULE_OPERATORS = ")
|
buffer.WriteString("window.WAF_RULE_OPERATORS = ")
|
||||||
buffer.Write(wafOperatorsJSON)
|
buffer.Write(wafOperatorsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
// WAF验证码类型
|
||||||
|
captchaTypesJSON, err := json.Marshal(firewallconfigs.FindAllCaptchaTypes())
|
||||||
|
if err != nil {
|
||||||
|
logs.Println("ComponentsAction marshal captcha types failed: " + err.Error())
|
||||||
|
} else {
|
||||||
|
buffer.WriteString("window.WAF_CAPTCHA_TYPES = ")
|
||||||
|
buffer.Write(captchaTypesJSON)
|
||||||
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
fp, err := os.OpenFile(filepath.Clean(Tea.PublicFile("/js/components.src.js")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
|
fp, err := os.OpenFile(filepath.Clean(Tea.PublicFile("/js/components.src.js")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_COND_COMPONENTS = ")
|
buffer.WriteString("window.REQUEST_COND_COMPONENTS = ")
|
||||||
buffer.Write(typesJSON)
|
buffer.Write(typesJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 条件操作符
|
// 条件操作符
|
||||||
@@ -81,7 +81,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_COND_OPERATORS = ")
|
buffer.WriteString("window.REQUEST_COND_OPERATORS = ")
|
||||||
buffer.Write(requestOperatorsJSON)
|
buffer.Write(requestOperatorsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求变量
|
// 请求变量
|
||||||
@@ -91,7 +91,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.REQUEST_VARIABLES = ")
|
buffer.WriteString("window.REQUEST_VARIABLES = ")
|
||||||
buffer.Write(requestVariablesJSON)
|
buffer.Write(requestVariablesJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指标
|
// 指标
|
||||||
@@ -101,7 +101,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.METRIC_HTTP_KEYS = ")
|
buffer.WriteString("window.METRIC_HTTP_KEYS = ")
|
||||||
buffer.Write(metricHTTPKeysJSON)
|
buffer.Write(metricHTTPKeysJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP地址阈值项目
|
// IP地址阈值项目
|
||||||
@@ -111,7 +111,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ")
|
buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ")
|
||||||
buffer.Write(ipAddrThresholdItemsJSON)
|
buffer.Write(ipAddrThresholdItemsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP地址阈值动作
|
// IP地址阈值动作
|
||||||
@@ -121,7 +121,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.IP_ADDR_THRESHOLD_ACTIONS = ")
|
buffer.WriteString("window.IP_ADDR_THRESHOLD_ACTIONS = ")
|
||||||
buffer.Write(ipAddrThresholdActionsJSON)
|
buffer.Write(ipAddrThresholdActionsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
// WAF操作符
|
// WAF操作符
|
||||||
@@ -131,7 +131,17 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
|||||||
} else {
|
} else {
|
||||||
buffer.WriteString("window.WAF_RULE_OPERATORS = ")
|
buffer.WriteString("window.WAF_RULE_OPERATORS = ")
|
||||||
buffer.Write(wafOperatorsJSON)
|
buffer.Write(wafOperatorsJSON)
|
||||||
buffer.Write([]byte{'\n', '\n'})
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
// WAF验证码类型
|
||||||
|
captchaTypesJSON, err := json.Marshal(firewallconfigs.FindAllCaptchaTypes())
|
||||||
|
if err != nil {
|
||||||
|
logs.Println("ComponentsAction marshal captcha types failed: " + err.Error())
|
||||||
|
} else {
|
||||||
|
buffer.WriteString("window.WAF_CAPTCHA_TYPES = ")
|
||||||
|
buffer.Write(captchaTypesJSON)
|
||||||
|
buffer.Write([]byte{';', '\n', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentsData = buffer.Bytes()
|
componentsData = buffer.Bytes()
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ Vue.component("http-firewall-captcha-options-viewer", {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
options: options,
|
options: options,
|
||||||
summary: ""
|
summary: "",
|
||||||
|
captchaTypes: window.WAF_CAPTCHA_TYPES
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -43,9 +44,19 @@ Vue.component("http-firewall-captcha-options-viewer", {
|
|||||||
if (this.options.failBlockScopeAll) {
|
if (this.options.failBlockScopeAll) {
|
||||||
summaryList.push("全局封禁")
|
summaryList.push("全局封禁")
|
||||||
}
|
}
|
||||||
|
let that = this
|
||||||
|
let typeDef = this.captchaTypes.$find(function (k, v) {
|
||||||
|
return v.code == that.options.captchaType
|
||||||
|
})
|
||||||
|
if (typeDef != null) {
|
||||||
|
summaryList.push("默认验证方式:" + typeDef.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.options.captchaType == "default") {
|
||||||
if (this.options.uiIsOn) {
|
if (this.options.uiIsOn) {
|
||||||
summaryList.push("定制UI")
|
summaryList.push("定制UI")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (summaryList.length == 0) {
|
if (summaryList.length == 0) {
|
||||||
this.summary = "默认配置"
|
this.summary = "默认配置"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
let options = this.vCaptchaOptions
|
let options = this.vCaptchaOptions
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {
|
options = {
|
||||||
|
captchaType: "default",
|
||||||
countLetters: 0,
|
countLetters: 0,
|
||||||
life: 0,
|
life: 0,
|
||||||
maxFails: 0,
|
maxFails: 0,
|
||||||
@@ -27,11 +28,17 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
if (options.countLetters <= 0) {
|
if (options.countLetters <= 0) {
|
||||||
options.countLetters = 6
|
options.countLetters = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.captchaType == null || options.captchaType.length == 0) {
|
||||||
|
options.captchaType = "default"
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
options: options,
|
options: options,
|
||||||
isEditing: false,
|
isEditing: false,
|
||||||
summary: "",
|
summary: "",
|
||||||
uiBodyWarning: ""
|
uiBodyWarning: "",
|
||||||
|
captchaTypes: window.WAF_CAPTCHA_TYPES
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -73,6 +80,9 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
"options.failBlockScopeAll": function (v) {
|
"options.failBlockScopeAll": function (v) {
|
||||||
this.updateSummary()
|
this.updateSummary()
|
||||||
},
|
},
|
||||||
|
"options.captchaType": function (v) {
|
||||||
|
this.updateSummary()
|
||||||
|
},
|
||||||
"options.uiIsOn": function (v) {
|
"options.uiIsOn": function (v) {
|
||||||
this.updateSummary()
|
this.updateSummary()
|
||||||
},
|
},
|
||||||
@@ -102,9 +112,21 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
if (this.options.failBlockScopeAll) {
|
if (this.options.failBlockScopeAll) {
|
||||||
summaryList.push("全局封禁")
|
summaryList.push("全局封禁")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let that = this
|
||||||
|
let typeDef = this.captchaTypes.$find(function (k, v) {
|
||||||
|
return v.code == that.options.captchaType
|
||||||
|
})
|
||||||
|
if (typeDef != null) {
|
||||||
|
summaryList.push("默认验证方式:" + typeDef.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.options.captchaType == "default") {
|
||||||
if (this.options.uiIsOn) {
|
if (this.options.uiIsOn) {
|
||||||
summaryList.push("定制UI")
|
summaryList.push("定制UI")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (summaryList.length == 0) {
|
if (summaryList.length == 0) {
|
||||||
this.summary = "默认配置"
|
this.summary = "默认配置"
|
||||||
} else {
|
} else {
|
||||||
@@ -121,6 +143,15 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
<div v-show="isEditing" style="margin-top: 0.5em">
|
<div v-show="isEditing" style="margin-top: 0.5em">
|
||||||
<table class="ui table definition selectable">
|
<table class="ui table definition selectable">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>默认验证方式</td>
|
||||||
|
<td>
|
||||||
|
<select class="ui dropdown auto-width" v-model="options.captchaType">
|
||||||
|
<option v-for="captchaDef in captchaTypes" :value="captchaDef.code">{{captchaDef.name}}</option>
|
||||||
|
</select>
|
||||||
|
<p class="comment" v-for="captchaDef in captchaTypes" v-if="captchaDef.code == options.captchaType">{{captchaDef.description}}</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">有效时间</td>
|
<td class="title">有效时间</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -158,7 +189,8 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
<p class="comment">是否在失败时全局封禁,默认为只封禁对单个网站的访问。</p>
|
<p class="comment">是否在失败时全局封禁,默认为只封禁对单个网站的访问。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
|
<tr v-show="options.captchaType == 'default'">
|
||||||
<td>验证码中数字个数</td>
|
<td>验证码中数字个数</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="ui dropdown auto-width" v-model="options.countLetters">
|
<select class="ui dropdown auto-width" v-model="options.countLetters">
|
||||||
@@ -166,12 +198,13 @@ Vue.component("http-firewall-captcha-options", {
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr v-show="options.captchaType == 'default'">
|
||||||
<td class="color-border">定制UI</td>
|
<td class="color-border">定制UI</td>
|
||||||
<td><checkbox v-model="options.uiIsOn"></checkbox></td>
|
<td><checkbox v-model="options.uiIsOn"></checkbox></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody v-show="options.uiIsOn">
|
<tbody v-show="options.uiIsOn && options.captchaType == 'default'">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="color-border">页面标题</td>
|
<td class="color-border">页面标题</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -7,14 +7,20 @@ Vue.component("http-firewall-config-box", {
|
|||||||
isPrior: false,
|
isPrior: false,
|
||||||
isOn: false,
|
isOn: false,
|
||||||
firewallPolicyId: 0,
|
firewallPolicyId: 0,
|
||||||
ignoreGlobalRules: false
|
ignoreGlobalRules: false,
|
||||||
|
defaultCaptchaType: "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (firewall.defaultCaptchaType == null || firewall.defaultCaptchaType.length == 0) {
|
||||||
|
firewall.defaultCaptchaType = "none"
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
firewall: firewall,
|
firewall: firewall,
|
||||||
moreOptionsVisible: false,
|
moreOptionsVisible: false,
|
||||||
execGlobalRules: !firewall.ignoreGlobalRules
|
execGlobalRules: !firewall.ignoreGlobalRules,
|
||||||
|
captchaTypes: window.WAF_CAPTCHA_TYPES
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -46,7 +52,7 @@ Vue.component("http-firewall-config-box", {
|
|||||||
<prior-checkbox :v-config="firewall" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
<prior-checkbox :v-config="firewall" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
||||||
<tbody v-show="(!vIsLocation && !vIsGroup) || firewall.isPrior">
|
<tbody v-show="(!vIsLocation && !vIsGroup) || firewall.isPrior">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">启用WAF</td>
|
<td class="title">启用Web防火墙</td>
|
||||||
<td>
|
<td>
|
||||||
<checkbox v-model="firewall.isOn"></checkbox>
|
<checkbox v-model="firewall.isOn"></checkbox>
|
||||||
<p class="comment">选中后,表示启用当前网站的WAF功能。</p>
|
<p class="comment">选中后,表示启用当前网站的WAF功能。</p>
|
||||||
@@ -55,6 +61,15 @@ Vue.component("http-firewall-config-box", {
|
|||||||
</tbody>
|
</tbody>
|
||||||
<more-options-tbody @change="changeOptionsVisible" v-show="firewall.isOn"></more-options-tbody>
|
<more-options-tbody @change="changeOptionsVisible" v-show="firewall.isOn"></more-options-tbody>
|
||||||
<tbody v-show="moreOptionsVisible">
|
<tbody v-show="moreOptionsVisible">
|
||||||
|
<tr>
|
||||||
|
<td>人机识别验证方式</td>
|
||||||
|
<td>
|
||||||
|
<select class="ui dropdown auto-width" v-model="firewall.defaultCaptchaType">
|
||||||
|
<option value="none">默认</option>
|
||||||
|
<option v-for="captchaType in captchaTypes" :value="captchaType.code">{{captchaType.name}}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>启用系统全局规则</td>
|
<td>启用系统全局规则</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>验证码动作设置</td>
|
<td>人机识别动作配置</td>
|
||||||
<td>
|
<td>
|
||||||
<http-firewall-captcha-options-viewer :v-captcha-options="firewallPolicy.captchaOptions"></http-firewall-captcha-options-viewer>
|
<http-firewall-captcha-options-viewer :v-captcha-options="firewallPolicy.captchaOptions"></http-firewall-captcha-options-viewer>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>验证码动作配置</td>
|
<td>人机识别动作配置</td>
|
||||||
<td>
|
<td>
|
||||||
<http-firewall-captcha-options :v-captcha-options="firewallPolicy.captchaOptions"></http-firewall-captcha-options>
|
<http-firewall-captcha-options :v-captcha-options="firewallPolicy.captchaOptions"></http-firewall-captcha-options>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user