perf: 登录资产的 ACL 支持 ip 控制

This commit is contained in:
ibuler
2023-05-29 16:15:21 +08:00
committed by Jiangjie.Bai
parent fcdcf29efa
commit 3500ab89f5
11 changed files with 98 additions and 34 deletions

View File

@@ -2,10 +2,10 @@
<div class="c-weektime">
<div class="c-schedue" />
<div :class="{'c-schedue': true, 'c-schedue-notransi': mode}" :style="styleValue" />
<table class="c-weektime-table" :class="{'c-min-table': colspan < 2}">
<table :class="{'c-min-table': colspan < 2}" class="c-weektime-table">
<thead class="c-weektime-head">
<tr>
<th rowspan="8" class="week-td">{{ this.$t('common.WeekCronSelect.WeekOrTime') }}</th>
<th class="week-td" rowspan="8">{{ this.$t('common.WeekCronSelect.WeekOrTime') }}</th>
<th :colspan="12 * colspan">00:00 - 12:00</th>
<th :colspan="12 * colspan">12:00 - 24:00</th>
</tr>
@@ -19,17 +19,17 @@
<td
v-for="n in t.child"
:key="`${n.row}-${n.col}`"
:data-week="n.row"
:data-time="n.col"
:class="selectClasses(n)"
:data-time="n.col"
:data-week="n.row"
class="weektime-atom-item"
@mouseenter="cellEnter(n)"
@mousedown="cellDown(n)"
@mouseenter="cellEnter(n)"
@mouseup="cellUp(n)"
/>
</tr>
<tr>
<td colspan="49" class="c-weektime-preview">
<td class="c-weektime-preview" colspan="49">
<div class="g-clearfix c-weektime-con">
<span class="g-pull-left">{{ this.$t('common.WeekCronSelect.CanDragSelect') }}</span>
<a class="g-pull-right" @click.prevent="clearWeektime">{{ this.$t('common.WeekCronSelect.ClearSelection') }}</a>
@@ -314,6 +314,7 @@ export default {
min-width: 640px;
position: relative;
display: inline-block;
padding-right: 20px;
}
.c-schedue {
background: #598fe6;

View File

@@ -0,0 +1,36 @@
<template>
<el-link v-right-click-target="target" :href="url" @click.prevent="openLink">
<slot />
</el-link>
</template>
<script>
export default {
name: 'RightClickLink',
directives: {
'right-click-target': {
inserted(el, binding) {
el.addEventListener('contextmenu', (event) => {
event.preventDefault()
window.open(binding.value, '_blank')
})
}
}
},
props: {
url: {
type: String,
required: true
},
target: {
type: String,
default: '_blank'
}
},
methods: {
openLink() {
window.open(this.url, this.target)
}
}
}
</script>

View File

@@ -2,9 +2,9 @@
<div>
<img v-if="icon" :src="icon" alt="icon" class="icon">
<el-link
class="detail"
:disabled="disabled"
:type="col.type || 'info'"
class="detail"
@click="goDetail"
>
<slot>
@@ -105,9 +105,6 @@ export default {
} else {
this.$router.push(this.detailRoute)
}
// const routeName = this.formatterArgs.route
// this.$log.debug('Will go to detail route: ', routeName)
// this.$router.push({ name: routeName, params: { id: this.row.id }, query: routeQuery })
}
}
}

View File

@@ -148,7 +148,7 @@
"users": "User",
"Rules": "Rule",
"Action": "Action",
"ip_group_help_text": "* means match all. Example: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64",
"ipGroupHelpText": "* means match all. Example: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64",
"apply_login_account": "Apply login account"
},
"applications": {
@@ -742,7 +742,7 @@
"noAnnouncement": "No announcement",
"lastCannotBeDeleteMsg": "The last one can't be delete",
"InvalidJson": "Not a valid json format",
"time_period": "Time period",
"timePeriod": "Time period",
"CronTab": {
"newCron": "new cron",
"timeExpression": "time expression",

View File

@@ -127,7 +127,7 @@
"AccountUsername": "アカウント (ユーザー名)",
"username": "ユーザー名",
"ip_group": "IPグループ",
"ip_group_help_text": "* はすべてにマッチすることを示します。例: 192.168.10.1、192.168.1.0/24、10.1.1-10.1.1. 20、2001:db8:2de::e 13、2001:db8:1a:1110::/64",
"ipGroupHelpText": "* はすべてにマッチすることを示します。例: 192.168.10.1、192.168.1.0/24、10.1.1-10.1.1. 20、2001:db8:2de::e 13、2001:db8:1a:1110::/64",
"action": "アクション",
"Rules": "ルール",
"Action": "アクション",
@@ -745,7 +745,7 @@
"noAnnouncement": "公告なし",
"lastCannotBeDeleteMsg": "最後の項目は削除できません",
"InvalidJson": "JSONの合法的ではありません",
"time_period": "時間帯",
"timePeriod": "時間帯",
"FormatError": "フォーマットエラー",
"NotSpecialEmoji": "特殊な表情記号の入力は許可されていません",
"notAlphanumericUnderscore": "数字、文字、アンダースコアのみ入力可能",

View File

@@ -115,6 +115,8 @@
}
},
"acl": {
"LoginIP": "登录 IP",
"UserIP": "登录 IP",
"apply_login_account": "申请登录账号",
"IgnoreCase": "忽略大小写",
"Content": "内容",
@@ -128,7 +130,7 @@
"reviewer": "审批人",
"username": "用户名",
"ip_group": "IP 组",
"ip_group_help_text": "* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64",
"ipGroupHelpText": "* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64",
"action": "动作",
"Rules": "规则",
"Action": "动作",
@@ -463,6 +465,7 @@
"ReLoginErr": "登录时长已超过 5 分钟,请重新登录"
},
"common": {
"OtherRules": "其它规则",
"MatchedCount": "匹配结果",
"SelectAttrs": "选择属性",
"MatchResult": "匹配结果",
@@ -510,7 +513,7 @@
"ConvenientOperate": "便捷操作",
"Overview": "概览",
"Now": "现在",
"EnterToContinue": "按回车继续输入",
"EnterToContinue": "按下 Enter 继续输入",
"SpecificInfo": "特殊信息",
"CollectionSucceed": "收藏成功",
"CancelCollection": "取消收藏",
@@ -629,7 +632,7 @@
"CopySuccess": "复制成功",
"Enable": "启用",
"On/Off": "启/停",
"EnterForSearch": "按回车进行搜索",
"EnterForSearch": "按下 Enter 进行搜索",
"Export": "导出",
"Import": "导入",
"ContinueImport": "继续导入",
@@ -788,7 +791,7 @@
"noAnnouncement": "暂无公告",
"lastCannotBeDeleteMsg": "最后一项,不能被删除",
"InvalidJson": "不是合法 JSON",
"time_period": "时段",
"timePeriod": "时段",
"FormatError": "格式错误",
"NotSpecialEmoji": "不允许输入特殊表情符号",
"notAlphanumericUnderscore": "只能输入字母、数字、下划线",
@@ -1365,7 +1368,8 @@
"AppletHosts": "应用发布机",
"uploadZipTips": "请上传 zip 格式的文件",
"HostDeployment": "发布机部署",
"TerminalStat": "CPU/内存/磁盘"
"TerminalStat": "CPU/内存/磁盘",
"Endpoint": "端点"
},
"sessions": {
"SetToDefaultStorage": "设置为默认存储",

View File

@@ -8,6 +8,7 @@ import rules from '@/components/DataForm/rules'
import { userJSONSelectMeta } from '@/views/users/const'
import { assetJSONSelectMeta } from '@/views/assets/const'
import AccountFormatter from '@/views/perms/AssetPermission/components/AccountFormatter.vue'
import { WeekCronSelect } from '@/components/FormFields'
export default {
name: 'AclCreateUpdate',
@@ -17,21 +18,42 @@ export default {
data() {
return {
initial: {
accounts: ['@ALL']
accounts: ['@ALL'],
rules: [
{
ip_group: ['*']
}
]
},
fields: [
[this.$t('common.Basic'), ['name']],
[this.$t('common.Basic'), ['name', 'priority']],
[this.$t('users.Users'), ['users']],
[this.$t('assets.Asset'), ['assets']],
[this.$t('accounts.Accounts'), ['accounts']],
[this.$t('acl.Rules'), ['rules']],
[this.$t('common.Action'), ['action', 'reviewers']],
[this.$t('common.Other'), ['priority', 'is_active', 'comment']]
[this.$t('common.Other'), ['is_active', 'comment']]
],
fieldsMeta: {
priority: {
rules: [rules.Required]
},
assets: assetJSONSelectMeta(this),
rules: {
fields: [
'ip_group', 'time_period'
],
fieldsMeta: {
ip_group: {
label: this.$t('acl.LoginIP'),
helpText: this.$t('acl.ipGroupHelpText')
},
time_period: {
label: this.$t('common.timePeriod'),
component: WeekCronSelect
}
}
},
users: userJSONSelectMeta(this),
accounts: {
component: AccountFormatter,

View File

@@ -27,13 +27,13 @@ export default {
accounts: ['@ALL']
},
fields: [
[this.$t('common.Basic'), ['name']],
[this.$t('common.Basic'), ['name', 'priority']],
[this.$t('perms.User'), ['users']],
[this.$t('perms.Asset'), ['assets']],
[this.$t('perms.Account'), ['accounts']],
[this.$t('acl.CommandGroup'), ['command_groups']],
[this.$t('common.action'), ['action', 'reviewers']],
[this.$t('common.Other'), ['priority', 'is_active', 'comment']]
[this.$t('common.Other'), ['is_active', 'comment']]
],
url: '/api/v1/acls/command-filter-acls/',
createSuccessNextRoute: { name: 'CommandFilterAclList' },

View File

@@ -1,7 +1,7 @@
<template>
<GenericCreateUpdatePage
v-bind="$data"
:after-get-form-value="afterGetFormValue"
v-bind="$data"
/>
</template>
@@ -19,13 +19,15 @@ export default {
return {
initial: {
action: 'reject',
rules: {
ip_group: ['*']
},
user: this.$route.query.user,
users: {
username_group: ''
}
},
rules: [
{
ip_group: ['*']
}
]
},
url: '/api/v1/acls/login-acls/',
hasDetailInMsg: false,
@@ -74,10 +76,10 @@ export default {
fieldsMeta: {
ip_group: {
label: this.$t('acl.ip_group'),
helpText: this.$t('acl.ip_group_help_text')
helpText: this.$t('acl.ipGroupHelpText')
},
time_period: {
label: this.$t('common.time_period'),
label: this.$t('common.timePeriod'),
component: WeekCronSelect
}
}

View File

@@ -23,7 +23,7 @@
@change="handleTagChange"
/>
<span v-if="showAddTemplate">
<el-button size="small" style="margin-left: 10px" type="primary" @click="showTemplateDialog=true">
<el-button size="small" type="primary" @click="showTemplateDialog=true">
{{ $t('common.TemplateAdd') }}
</el-button>
{{ addTemplateHelpText }}

View File

@@ -1,13 +1,14 @@
<template>
<GenericCreateUpdatePage
v-bind="$data"
:create-success-next-route="successUrl"
:update-success-next-route="successUrl"
v-bind="$data"
/>
</template>
<script>
import { GenericCreateUpdatePage } from '@/layout/components'
export default {
name: 'EndpointRuleCreateUpdate',
components: {
@@ -21,7 +22,8 @@ export default {
},
successUrl: { name: 'TerminalSetting', params: { activeMenu: 'EndpointRuleList' }},
fields: [
[this.$t('common.Basic'), ['name', 'ip_group', 'endpoint', 'priority']],
[this.$t('common.Basic'), ['name', 'priority']],
[this.$t('terminal.Endpoint'), ['ip_group', 'endpoint']],
[this.$t('common.Other'), ['comment']]
],
fieldsMeta: {