mirror of https://github.com/1Panel-dev/1Panel
feat: 增加cookie校验等
parent
3f52c079af
commit
a323f87ba0
|
@ -850,7 +850,6 @@ export default {
|
|||
default: '默认',
|
||||
deleteHelper: '相关应用状态不正常,请检查',
|
||||
toApp: '去已安装列表',
|
||||
enableCC: '开启CC攻击防护',
|
||||
cycle: '周期',
|
||||
frequency: '频率',
|
||||
ccHelper: '{0} 秒内累计请求同一URL超过 {1} 次,触发CC防御,封锁此IP',
|
||||
|
@ -859,6 +858,8 @@ export default {
|
|||
mustSave: '修改之后需要保存才能生效',
|
||||
fileExt: '文件扩展名',
|
||||
fileExtBlock: '文件扩展名黑名单',
|
||||
value: '值',
|
||||
enable: '开启',
|
||||
},
|
||||
nginx: {
|
||||
serverNamesHashBucketSizeHelper: '服务器名字的hash表大小',
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
:rules="rules"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-form-item prop="enable" :label="$t('website.enableCC')">
|
||||
<el-form-item prop="enable" :label="$t('website.enable')">
|
||||
<el-switch v-model="form.enable" @change="updateEnable"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item prop="cycle" :label="$t('website.cycle')">
|
||||
|
|
|
@ -12,13 +12,21 @@
|
|||
<el-tab-pane :label="'文件扩展名黑名单'" name="FileBlockList">
|
||||
<FileBlockList :id="id" v-if="index == 'FileBlockList'"></FileBlockList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'URL黑名单'" name="urlBlockList">
|
||||
<UrlList :id="id" :rule="'url'" v-if="index == 'urlBlockList'"></UrlList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'URL白名单'" name="urlWhiteList">
|
||||
<UrlList :id="id" :rule="'whiteurl'" v-if="index == 'urlWhiteList'"></UrlList>
|
||||
<ValueList :id="id" :rule="'whiteurl'" v-if="index == 'urlWhiteList'"></ValueList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'URL黑名单'" name="urlBlockList">
|
||||
<ValueList :id="id" :rule="'url'" v-if="index == 'urlBlockList'"></ValueList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'GET参数(args)校验'" name="args">
|
||||
<ValueList :id="id" :rule="'args'" v-if="index == 'args'"></ValueList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'POST参数校验'" name="post">
|
||||
<ValueList :id="id" :rule="'post'" v-if="index == 'post'"></ValueList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'Cookie黑名单'" name="cookie">
|
||||
<ValueList :id="id" :rule="'cookie'" v-if="index == 'cookie'"></ValueList>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'禁止爬虫'"></el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
|
@ -26,7 +34,7 @@ import { computed, ref } from 'vue';
|
|||
import CCDeny from './ccdeny/index.vue';
|
||||
import IpList from './ip-list/index.vue';
|
||||
import FileBlockList from './file-block-list/index.vue';
|
||||
import UrlList from './url-list/index.vue';
|
||||
import ValueList from './value-list/index.vue';
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
<template>
|
||||
<el-row>
|
||||
<el-col :span="10" :offset="2">
|
||||
<el-form-item prop="enable" :label="$t('website.enable')">
|
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
|
||||
</el-form-item>
|
||||
<ComplexTable :data="data" v-loading="loading">
|
||||
<template #toolbar>
|
||||
<el-button type="primary" icon="Plus" @click="openCreate">
|
||||
{{ $t('commons.button.add') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table-column :label="'URL'">
|
||||
<el-table-column :label="$t('website.value')">
|
||||
<template #default="{ row }">
|
||||
<fu-read-write-switch :data="row.value" v-model="row.edit" write-trigger="onDblclick">
|
||||
<el-form-item :error="row.error">
|
||||
|
@ -21,7 +24,7 @@
|
|||
</fu-read-write-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.table.operate')">
|
||||
<el-table-column :label="$t('commons.table.operate')" width="100px">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="primary" @click="remove($index)">
|
||||
{{ $t('commons.button.delete') }}
|
||||
|
@ -40,7 +43,7 @@
|
|||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { WebSite } from '@/api/interface/website';
|
||||
import { GetWafConfig } from '@/api/modules/website';
|
||||
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import ComplexTable from '@/components/complex-table/index.vue';
|
||||
import { SaveFileContent } from '@/api/modules/files';
|
||||
|
@ -75,13 +78,18 @@ let fileUpdate = reactive({
|
|||
path: '',
|
||||
content: '',
|
||||
});
|
||||
let enableUpdate = ref<WebSite.WafUpdate>({
|
||||
websiteId: 0,
|
||||
key: '$UrlDeny',
|
||||
enable: false,
|
||||
});
|
||||
|
||||
const get = async () => {
|
||||
data.value = [];
|
||||
loading.value = true;
|
||||
const res = await GetWafConfig(req.value);
|
||||
loading.value = false;
|
||||
|
||||
enableUpdate.value.enable = res.data.enable;
|
||||
if (res.data.content != '') {
|
||||
const urlList = res.data.content.split('\n');
|
||||
urlList.forEach((value) => {
|
||||
|
@ -106,6 +114,13 @@ const openCreate = () => {
|
|||
data.value.unshift({ value: '', edit: true, error: '' });
|
||||
};
|
||||
|
||||
const updateEnable = async (enable: boolean) => {
|
||||
enableUpdate.value.enable = enable;
|
||||
loading.value = true;
|
||||
await UpdateWafEnable(enableUpdate.value);
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
let urlList = '';
|
||||
data.value.forEach((row) => {
|
||||
|
@ -126,9 +141,25 @@ const submit = async () => {
|
|||
});
|
||||
};
|
||||
|
||||
const getKey = (rule: string) => {
|
||||
switch (rule) {
|
||||
case 'url':
|
||||
return '$UrlDeny';
|
||||
case 'whiteurl':
|
||||
return '$whiteModule';
|
||||
case 'post':
|
||||
return '$postMatch';
|
||||
case 'url':
|
||||
return '$UrlDeny';
|
||||
case 'url':
|
||||
return '$UrlDeny';
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
req.value.websiteId = id.value;
|
||||
req.value.rule = rule.value;
|
||||
enableUpdate.value.key = getKey(rule.value);
|
||||
get();
|
||||
});
|
||||
</script>
|
Loading…
Reference in New Issue