2020-09-20 20:12:43 +08:00
Vue . component ( "http-firewall-config-box" , {
2021-10-07 16:47:14 +08:00
props : [ "v-firewall-config" , "v-is-location" , "v-is-group" , "v-firewall-policy" ] ,
2020-09-20 20:12:43 +08:00
data : function ( ) {
let firewall = this . vFirewallConfig
if ( firewall == null ) {
firewall = {
2020-09-23 18:43:38 +08:00
isPrior : false ,
2020-09-20 20:12:43 +08:00
isOn : false ,
2023-03-01 16:46:49 +08:00
firewallPolicyId : 0 ,
2023-11-15 15:12:58 +08:00
ignoreGlobalRules : false ,
defaultCaptchaType : "none"
2020-09-20 20:12:43 +08:00
}
}
2023-11-15 15:12:58 +08:00
if ( firewall . defaultCaptchaType == null || firewall . defaultCaptchaType . length == 0 ) {
firewall . defaultCaptchaType = "none"
}
2023-11-29 16:57:58 +08:00
let allCaptchaTypes = window . WAF _CAPTCHA _TYPES . $copy ( )
// geetest
let geeTestIsOn = false
if ( this . vFirewallPolicy != null && this . vFirewallPolicy . captchaAction != null && this . vFirewallPolicy . captchaAction . geeTestConfig != null ) {
geeTestIsOn = this . vFirewallPolicy . captchaAction . geeTestConfig . isOn
}
// 如果没有启用geetest, 则还原
if ( ! geeTestIsOn && firewall . defaultCaptchaType == "geetest" ) {
firewall . defaultCaptchaType = "none"
}
2020-09-20 20:12:43 +08:00
return {
2023-03-01 16:46:49 +08:00
firewall : firewall ,
2023-03-06 16:40:42 +08:00
moreOptionsVisible : false ,
2023-11-15 15:12:58 +08:00
execGlobalRules : ! firewall . ignoreGlobalRules ,
2023-11-29 16:57:58 +08:00
captchaTypes : allCaptchaTypes ,
geeTestIsOn : geeTestIsOn
2023-03-06 16:40:42 +08:00
}
} ,
watch : {
execGlobalRules : function ( v ) {
this . firewall . ignoreGlobalRules = ! v
2023-03-01 16:46:49 +08:00
}
} ,
methods : {
changeOptionsVisible : function ( v ) {
this . moreOptionsVisible = v
2020-09-20 20:12:43 +08:00
}
} ,
template : ` <div>
< input type = "hidden" name = "firewallJSON" : value = "JSON.stringify(firewall)" / >
2023-03-01 16:46:49 +08:00
< table class = "ui table selectable definition" v - show = "!vIsGroup" >
< tr >
< td class = "title" > 全局WAF策略 < / t d >
< td >
< div v - if = "vFirewallPolicy != null" > { { vFirewallPolicy . name } } < span v - if = "vFirewallPolicy.modeInfo != null" > & nbsp ; < span : class = "{green: vFirewallPolicy.modeInfo.code == 'defend', blue: vFirewallPolicy.modeInfo.code == 'observe', grey: vFirewallPolicy.modeInfo.code == 'bypass'}" > [ { { vFirewallPolicy . modeInfo . name } } ] < / s p a n > & n b s p ; < / s p a n > < l i n k - i c o n : h r e f = " ' / s e r v e r s / c o m p o n e n t s / w a f / p o l i c y ? f i r e w a l l P o l i c y I d = ' + v F i r e w a l l P o l i c y . i d " > < / l i n k - i c o n >
2023-08-07 11:32:36 +08:00
< p class = "comment" > 当前网站所在集群的设置 。 < / p >
2023-03-01 16:46:49 +08:00
< / d i v >
< span v - else class = "red" > 当前集群没有设置WAF策略 , 当前配置无法生效 。 < / s p a n >
< / t d >
< / t r >
< / t a b l e >
2020-09-20 20:12:43 +08:00
< table class = "ui table selectable definition" >
2021-10-07 16:47:14 +08:00
< prior - checkbox : v - config = "firewall" v - if = "vIsLocation || vIsGroup" > < / p r i o r - c h e c k b o x >
< tbody v - show = "(!vIsLocation && !vIsGroup) || firewall.isPrior" >
2023-03-01 16:46:49 +08:00
< tr >
2023-11-15 15:12:58 +08:00
< td class = "title" > 启用Web防火墙 < / t d >
2020-09-20 20:12:43 +08:00
< td >
2023-03-01 16:46:49 +08:00
< checkbox v - model = "firewall.isOn" > < / c h e c k b o x >
2023-04-21 17:51:25 +08:00
< p class = "comment" > 选中后 , 表示启用当前网站的WAF功能 。 < / p >
2020-09-20 20:12:43 +08:00
< / t d >
< / t r >
2023-03-01 16:46:49 +08:00
< / t b o d y >
2023-09-14 09:18:36 +08:00
< more - options - tbody @ change = "changeOptionsVisible" v - show = "firewall.isOn" > < / m o r e - o p t i o n s - t b o d y >
2023-03-01 16:46:49 +08:00
< tbody v - show = "moreOptionsVisible" >
2023-11-15 15:12:58 +08:00
< tr >
< td > 人机识别验证方式 < / t d >
< td >
< select class = "ui dropdown auto-width" v - model = "firewall.defaultCaptchaType" >
< option value = "none" > 默认 < / o p t i o n >
2023-11-29 16:57:58 +08:00
< option v - for = "captchaType in captchaTypes" v - if = "captchaType.code != 'geetest' || geeTestIsOn" : value = "captchaType.code" > { { captchaType . name } } < / o p t i o n >
2023-11-15 15:12:58 +08:00
< / s e l e c t >
2024-05-12 19:11:40 +08:00
< p class = "comment" v - if = "firewall.defaultCaptchaType == 'none'" > 使用系统默认的设置 。 你需要在入站规则中添加规则集来决定哪些请求需要人机识别验证 。 < / p >
< p class = "comment" v - for = "captchaType in captchaTypes" v - if = "captchaType.code == firewall.defaultCaptchaType" > { { captchaType . description } } 你需要在入站规则中添加规则集来决定哪些请求需要人机识别验证 。 < / p >
2023-11-15 15:12:58 +08:00
< / t d >
< / t r >
2020-09-20 20:12:43 +08:00
< tr >
2023-03-06 16:40:42 +08:00
< td > 启用系统全局规则 < / t d >
2020-09-20 20:12:43 +08:00
< td >
2023-03-06 16:40:42 +08:00
< checkbox v - model = "execGlobalRules" > < / c h e c k b o x >
< p class = "comment" > 选中后 , 表示使用系统全局WAF策略中定义的规则 。 < / p >
2020-09-20 20:12:43 +08:00
< / t d >
< / t r >
< / t b o d y >
< / t a b l e >
< div class = "margin" > < / d i v >
< / d i v > `
} )