feat: 权限管理中增加命令过滤菜单; 路由中添加CommandFilterACL,CommandGroup; 添加CommandFilterAclList,Create,Update;添加CommandGroupList,Create,Update;

This commit is contained in:
Bai
2022-12-04 18:30:37 +08:00
parent 0ea46e9ee2
commit 1c00db1978
13 changed files with 498 additions and 16 deletions

View File

@@ -9,11 +9,13 @@
"PleaseClickLeftAssetToViewGatheredUser": "Gathered user list, please click on the assets on the left to view"
},
"acl": {
"CommandFilterACL": "Command filter",
"CommandGroup": "Command group",
"name": "Name",
"user_username": "User (Username)",
"asset_name": "Asset (Name)",
"asset_address": "Asset (IP/Host)",
"account_username": "Account (Username)",
"UserUsername": "User (Username)",
"AssetName": "Asset (Name)",
"AssetAddress": "Asset (IP/Host)",
"AccountUsername": "Account (Username)",
"reviewer": "Reviewer",
"username": "Username",
"ip_group": "IP group",
@@ -846,6 +848,14 @@
"UserAclLists": "User acl lists",
"UserAclDetail": "User acl detail",
"AssetAclList": "Asset Acl",
"CommandFilterAclList": "Command Acl",
"CommandFilterAclCreate": "Command Acl create",
"CommandFilterAclDetail": "Command Acl detail",
"CommandFilterAclUpdate": "command Acl update",
"CommandGroupList": "Command group",
"CommandGroupCreate": "Command group create",
"CommandGroupDetail": "Command group detail",
"CommandGroupUpdate": "Command group update",
"AssetAclCreate": "Asset acl create",
"AssetAclUpdate": "Asset acl update",
"AssetAclDetail": "Asset acl detail",

View File

@@ -9,12 +9,14 @@
"PleaseClickLeftAssetToViewGatheredUser": "ユーザーリストを収集し、左側の資産をクリックして表示します。"
},
"acl": {
"CommandFilterACL": "命令フィルタリング",
"CommandGroup": "コマンドグループ",
"name": "名前",
"user_username": "ユーザー (ユーザー名)",
"asset_name": "アセット (名前)",
"asset_address": "アセット (IP/ホスト名)",
"UserUsername": "ユーザー (ユーザー名)",
"AssetName": "アセット (名前)",
"AssetAddress": "アセット (IP/ホスト名)",
"reviewer": "決裁人",
"account_username": "アカウント (ユーザー名)",
"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",
@@ -858,6 +860,14 @@
"UserLoginACLUpdate": "ユーザーログインルールの更新",
"UserAclDetail": "ユーザーログインルールの詳細",
"AssetAclList": "アセットログイン",
"CommandFilterAclList": "命令フィルタリング",
"CommandFilterAclCreate": "コマンド フィルター規則を作成する",
"CommandFilterAclDetail": "CommandFilterAclDetail",
"CommandFilterAclUpdate": "コマンド フィルター規則を更新する",
"CommandGroupList": "コマンド グループ",
"CommandGroupCreate": "コマンド グループの作成",
"CommandGroupDetail": "コマンド グループの詳細",
"CommandGroupUpdate": "コマンド グループの更新",
"AssetAclCreate": "アセット登録ルールの作成",
"AssetAclUpdate": "アセット登録ルールの更新",
"AssetAclDetail": "アセット登録ルール詳細",

View File

@@ -9,11 +9,13 @@
"PleaseClickLeftAssetToViewGatheredUser": "收集用户列表,点击左侧资产进行查看"
},
"acl": {
"CommandFilterACL": "命令过滤",
"CommandGroup": "命令组",
"name": "名称",
"user_username": "用户(用户名)",
"asset_name": "资产(名称)",
"asset_address": "资产IP/主机名)",
"account_username": "账号(用户名)",
"UserUsername": "用户(用户名)",
"AssetName": "资产(名称)",
"AssetAddress": "资产IP/主机名)",
"AccountUsername": "账号(用户名)",
"reviewer": "审批人",
"username": "用户名",
"ip_group": "IP 组",
@@ -933,6 +935,14 @@
"UserLoginACLUpdate": "更新用户登录规则",
"UserAclDetail": "用户登录规则详情",
"AssetAclList": "资产登录",
"CommandFilterAclList": "命令过滤",
"CommandFilterAclCreate": "创建命令过滤规则",
"CommandFilterAclDetail": "命令过滤规则详情",
"CommandFilterAclUpdate": "更新命令过滤规则",
"CommandGroupList": "命令组",
"CommandGroupCreate": "创建命令组",
"CommandGroupDetail": "命令组详情",
"CommandGroupUpdate": "更新命令组",
"AssetAclCreate": "创建资产登录规则",
"AssetAclUpdate": "更新资产登录规则",
"AssetAclDetail": "资产登录规则详情",

View File

@@ -78,5 +78,83 @@ export default [
meta: { title: i18n.t('route.AssetAclUpdate') }
}
]
},
{
path: 'cmd-acls',
component: empty,
redirect: '',
meta: {
title: i18n.t('route.CommandFilterAclList'),
app: 'acls',
resource: 'commandfilteracl'
},
children: [
// Command Filter ACL
{
path: '',
name: 'CommandFilterAclList',
component: () => import('@/views/acl/CommandAcl/index'),
hidden: true,
meta: { title: i18n.t('route.CommandFilterAclList') }
},
{
path: 'create',
name: 'CommandFilterAclCreate',
component: () => import('@/views/acl/CommandAcl/CommandFilterAcl/CommandFilterAclCreateUpdate'),
hidden: true,
meta: { title: i18n.t('route.CommandFilterAclCreate') }
},
{
path: ':id',
name: 'CommandFilterAclDetail',
component: () => import('@/views/acl/CommandAcl/CommandFilterAcl/CommandFilterAclDetail'),
hidden: true,
meta: { title: i18n.t('route.CommandFilterAclDetail') }
},
{
path: ':id/update',
name: 'CommandFilterAclUpdate',
component: () => import('@/views/acl/CommandAcl/CommandFilterAcl/CommandFilterAclCreateUpdate'),
hidden: true,
meta: { title: i18n.t('route.CommandFilterAclUpdate') }
},
// Command Group
{
path: '',
name: 'CommandGroupList',
component: () => import('@/views/acl/CommandAcl/CommandGroup/CommandGroupList'),
meta: { title: i18n.t('route.CommandGroupList') },
hidden: true,
app: 'acls',
resource: 'commandgroup'
},
{
path: 'create',
name: 'CommandGroupCreate',
component: () => import('@/views/acl/CommandAcl/CommandGroup/CommandGroupCreateUpdate'),
hidden: true,
meta: { title: i18n.t('route.CommandGroupCreate') },
app: 'acls',
resource: 'commandgroup'
},
{
path: ':id',
name: 'CommandGroupDetail',
component: () => import('@/views/acl/CommandAcl/CommandGroup/CommandGroupDetail'),
hidden: true,
meta: { title: i18n.t('route.CommandGroupDetail') },
app: 'acls',
resource: 'commandgroup'
},
{
path: ':id/update',
name: 'CommandGroupUpdate',
component: () => import('@/views/acl/CommandAcl/CommandGroup/CommandGroupCreateUpdate'),
hidden: true,
meta: { title: i18n.t('route.CommandGroupUpdate') },
app: 'acls',
resource: 'commandgroup'
}
]
}
]

View File

@@ -34,15 +34,15 @@ export default {
value: this.object.name
},
{
key: this.$t('acl.user_username'),
key: this.$t('acl.UserUsername'),
value: this.object.users.username_group.toString()
},
{
key: this.$t('acl.asset_name'),
key: this.$t('acl.AssetName'),
value: this.object.assets.name_group.toString()
},
{
key: this.$t('acl.asset_address'),
key: this.$t('acl.AssetAddress'),
value: this.object.assets.address_group.toString()
},
{

View File

@@ -15,7 +15,7 @@ export default {
url: '/api/v1/acls/login-asset-acls/',
columns: [
'name', 'user_username_group', 'hostname_group', 'ip_group', 'name_group',
'protocol_group', 'systemuser_username_group', 'reviewers', 'priority',
'reviewers', 'priority',
'is_active', 'comment', 'actions'
],
columnsShow: {

View File

@@ -0,0 +1,87 @@
<template>
<GenericCreateUpdatePage
:fields="fields"
:initial="initial"
:fields-meta="fieldsMeta"
:url="url"
v-bind="$data"
/>
</template>
<script>
import { GenericCreateUpdatePage } from '@/layout/components'
import rules from '@/components/DataForm/rules'
export default {
name: 'CommandFilterAclCreateUpdate',
components: {
GenericCreateUpdatePage
},
data() {
return {
initial: {
is_active: true
},
fields: [
[this.$t('common.Basic'), ['name']],
[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']]
],
url: '/api/v1/acls/command-filter-acls/',
createSuccessNextRoute: { name: 'CommandFilterAclList' },
fieldsMeta: {
users: {
fields: ['username_group']
},
assets: {
fields: ['name_group', 'address_group']
},
accounts: {
fields: ['username_group']
},
priority: {
// helpText: '优先级可选范围为1-1001最低优先级100最高优先级'
// helpText: this.$t('assets.CommandFilterRulePriorityHelpText')
},
action: {
},
command_groups: {
el: {
value: [],
ajax: {
url: '/api/v1/acls/command-groups/?fields_size=mini',
transformOption: (item) => {
return { label: item.name, value: item.id }
}
}
}
},
reviewers: {
hidden: (item) => item.action !== 'review',
rules: [rules.RequiredChange],
el: {
value: [],
ajax: {
url: '/api/v1/users/users/?fields_size=mini',
transformOption: (item) => {
return { label: item.name + '(' + item.username + ')', value: item.id }
}
}
}
},
is_active: {
type: 'checkbox'
}
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,13 @@
<template>
<div />
</template>
<script>
export default {
name: 'CommandFilterAclDetail'
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,95 @@
<template>
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
</template>
<script>
import { ListTable } from '@/components'
export default {
components: {
ListTable
},
data() {
return {
tableConfig: {
url: '/api/v1/acls/command-filter-acls/',
permissions: {
app: 'acls',
resource: 'commandfilteracl'
},
columns: [
'name', 'user_username_group', 'asset_name_group', 'asset_address_group',
'account_username_group', 'command_groups', 'action',
'date_created', 'created_by', 'org_name',
'comment', 'is_active', 'actions'
],
columnsShow: {
min: ['name', 'actions'],
default: [
'name', 'user_username_group', 'asset_name_group', 'asset_address_group',
'account_username_group', 'command_groups', 'comment', 'actions'
]
},
columnsMeta: {
user_username_group: {
prop: 'users.username_group',
showOverflowTooltip: true,
formatter: function(row) {
return <span> {row.users.username_group.toString()} </span>
},
label: this.$t('acl.UserUsername')
},
asset_name_group: {
prop: 'assets.name_group',
showOverflowTooltip: true,
formatter: function(row) {
return <span> {row.assets.name_group.toString()} </span>
},
label: this.$t('acl.AssetName')
},
asset_address_group: {
prop: 'assets.address_group',
showOverflowTooltip: true,
formatter: function(row) {
return <span> {row.assets.address_group.toString()} </span>
},
label: this.$t('acl.AssetAddress')
},
account_username_group: {
prop: 'accounts.username_group',
showOverflowTooltip: true,
formatter: function(row) {
return <span> {row.accounts.username_group.toString()} </span>
},
label: this.$t('acl.AccountUsername')
},
command_groups: {
label: this.$t('acl.CommandGroup'),
formatter: function(row) {
return <span> { row.command_groups.length }</span>
}
}
}
},
headerActions: {
hasRightActions: true,
hasExport: false,
hasImport: false,
hasRefresh: true,
hasSearch: true,
hasMoreActions: false,
createRoute: 'CommandFilterAclCreate',
canCreate: () => {
return this.$hasPerm('acls.add_commandfilteracl')
}
}
}
},
computed: {
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,60 @@
<template>
<GenericCreateUpdatePage
:fields="fields"
:initial="initial"
:fields-meta="fieldsMeta"
:url="url"
v-bind="$data"
/>
</template>
<script>
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
export default {
name: 'CommandGroupCreateUpdate',
components: { GenericCreateUpdatePage },
data() {
const regexPlaceholder = 'rm.*|reboot|shutdown'
const commandPlaceholder = 'rm\rreboot'
const commandHelpText = this.$t('assets.CommandFilterRuleContentHelpText')
const vm = this
return {
initial: {},
fields: [
[this.$t('common.Basic'), ['name', 'type', 'content', 'ignore_case', 'comment']]
],
url: `/api/v1/acls/command-groups/`,
createSuccessNextRoute: { name: 'CommandFilterAclList' },
fieldsMeta: {
type: {
on: {
change: ([val]) => {
if (val === 'command') {
vm.fieldsMeta.content.el.placeholder = commandPlaceholder
vm.fieldsMeta.content.helpText = commandHelpText
} else {
vm.fieldsMeta.content.el.placeholder = regexPlaceholder
vm.fieldsMeta.content.helpText = ''
}
}
}
},
content: {
type: 'input',
el: {
type: 'textarea',
placeholder: 'rm.*|reboot|shutdown',
rows: 4
},
helpText: ''
}
}
}
}
}
</script>
<style lang='less' scoped>
</style>

View File

@@ -0,0 +1,13 @@
<template>
<div />
</template>
<script>
export default {
name: 'CommandGroupDetail'
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,51 @@
<template>
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
</template>
<script>
import { ListTable } from '@/components'
export default {
components: {
ListTable
},
data() {
return {
tableConfig: {
url: '/api/v1/acls/command-groups/',
permissions: {
app: 'acls',
resource: 'commandgroup'
},
columns: [
'name', 'content', 'actions'
],
columnsShow: {
min: ['name', 'actions'],
default: ['name', 'content', 'actions']
},
columnsMeta: {
}
},
headerActions: {
hasRightActions: true,
hasExport: false,
hasImport: false,
hasRefresh: true,
hasSearch: true,
hasMoreActions: false,
createRoute: 'CommandGroupCreate',
canCreate: () => {
return this.$hasPerm('acls.add_commandgroup')
}
}
}
},
computed: {
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,55 @@
<template>
<TabPage
:active-menu.sync="config.activeMenu"
:submenu="config.submenu"
@tab-click="handleTabClick"
/>
</template>
<script>
import { TabPage } from '@/layout/components'
export default {
name: 'Index',
components: {
TabPage
},
data() {
return {
config: {
activeMenu: 'CommandFilterACL',
submenu: [
{
title: this.$t('acl.CommandFilterACL'),
name: 'CommandFilterACL',
component: () => import('@/views/acl/CommandAcl/CommandFilterAcl/CommandFilterAclList.vue')
},
{
title: this.$t('acl.CommandGroup'),
name: 'CommandGroup',
component: () => import('@/views/acl/CommandAcl/CommandGroup/CommandGroupList.vue')
}
]
}
}
},
mounted() {
},
methods: {
handleTabClick(tab) {
const query = _.cloneDeep(this.$route.query)
const newQuery = {
...query,
activeTab: tab.name
}
this.$nextTick(() => {
this.$router.replace({ query: newQuery })
})
}
}
}
</script>
<style scoped>
</style>