perf: 添加访问IP控制

This commit is contained in:
wangruidong
2023-10-31 14:28:32 +08:00
committed by Bryan
parent 378d82518a
commit 8c7c012785
6 changed files with 106 additions and 11 deletions

View File

@@ -2319,6 +2319,7 @@
},
"profile": {
"CreateAccessKey": "Create Access key",
"AccessIP": "Access IP",
"ApiKeyWarning": "To reduce the risk of AccessKey exposure, Secret is provided only during creation and cannot be queried again later. Please keep it safe.",
"PasskeyAddDisableInfo": "Your authentication source is {source}, and Passkey addition is not supported."
}

View File

@@ -2309,6 +2309,7 @@
},
"profile": {
"CreateAccessKey": "Create Access key",
"AccessIP": "Access IP",
"ApiKeyWarning": "AccessKeyの漏洩リスクを低減するため、Secretは作成時にのみ提供され、後で再度クエリできません。安全に保管してください。",
"PasskeyAddDisableInfo": "あなたの認証元は {source} であり、Passkeyの追加はサポートされていません。"
}

View File

@@ -1881,6 +1881,7 @@
},
"profile": {
"CreateAccessKey": "创建访问密钥",
"AccessIP": "访问IP",
"ApiKeyWarning": "为降低 AccessKey 泄露的风险,只在创建时提供 Secret后续不可再进行查询请妥善保存。",
"PasskeyAddDisableInfo": "你的认证来源是 {source}, 不支持添加 Passkey"
},

View File

@@ -1,5 +1,6 @@
import Layout from '@/layout'
import i18n from '@/i18n/i18n'
import empty from '@/layout/empty.vue'
export default {
path: '/profile',
@@ -54,15 +55,31 @@ export default {
},
{
path: '/profile/api-keys',
component: () => import('@/views/profile/ApiKey'),
name: 'ApiKey',
component: empty,
meta: {
title: i18n.t('common.nav.APIKey'),
icon: 'key',
permissions: ['authentication.view_accesskey'],
resource: 'accesskey',
app: 'authentication'
}
icon: 'key'
},
redirect: '',
children: [
{
path: '',
component: () => import('@/views/profile/ApiKey'),
name: 'ApiKey',
icon: 'key',
meta: { title: i18n.t('common.nav.APIKey'), permissions: ['authentication.view_accesskey'] }
},
{
path: ':id/update',
component: () => import('@/views/profile/ApiKeyCreateUpdate/index'),
name: 'ApiKeyCreateUpdate',
hidden: true,
meta: {
title: i18n.t('common.nav.APIKey'),
permissions: ['authentication.change_accesskey'],
activeMenu: '/profile/api-keys'
}
}
]
},
{
path: '/profile/temp-password',

View File

@@ -33,7 +33,7 @@
<script>
import { GenericListPage } from '@/layout/components'
import { DateFormatter } from '@/components/Table/TableFormatters'
import { DateFormatter, ArrayFormatter } from '@/components/Table/TableFormatters'
import Dialog from '@/components/Dialog/index.vue'
export default {
@@ -53,7 +53,7 @@ export default {
tableConfig: {
hasSelection: true,
url: ajaxUrl,
columns: ['id', 'secret', 'is_active', 'date_created', 'date_last_used', 'actions'],
columns: ['id', 'secret', 'ip_group', 'is_active', 'date_created', 'date_last_used', 'actions'],
columnsShow: {
min: ['id', 'actions']
},
@@ -71,10 +71,14 @@ export default {
label: this.$t('common.DateCreated'),
formatter: DateFormatter
},
ip_group: {
label: this.$t('profile.AccessIP'),
formatter: ArrayFormatter
},
actions: {
formatterArgs: {
hasUpdate: false,
hasClone: false,
updateRoute: 'ApiKeyCreateUpdate',
onDelete: function({ row }) {
this.$axios.delete(`${ajaxUrl}${row.id}/`).then(res => {
this.getRefsListTable.reloadTable()

View File

@@ -0,0 +1,71 @@
<template>
<GenericCreateUpdatePage v-bind="$data" />
</template>
<script>
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
export default {
name: 'ApiKeyCreateUpdate',
components: {
GenericCreateUpdatePage
},
data() {
return {
initial: {
rules: {
ip_group: ['*']
}
},
url: '/api/v1/authentication/access-keys/',
hasDetailInMsg: false,
fields: [
'ip_group'
],
fieldsMeta: {
rules: {
fields: [
'ip_group'
],
fieldsMeta: {
ip_group: {
label: this.$t('profile.AccessIP'),
helpText: this.$t('acl.ipGroupHelpText')
}
}
}
},
getUrl() {
const query = this.$route.query
const params = this.$route.params
let url = `/api/v1/authentication/access-keys/`
if (params.id) {
url = `${url}${params.id}/`
}
if (query.user) {
url = `${url}?user=${query.user}`
}
return url
},
cleanFormValue(value) {
if (!Array.isArray(value.ip_group)) {
value.ip_group = value.ip_group ? value.ip_group.split(',') : []
}
return value
},
updateSuccessNextRoute: {
name: 'ApiKeyCreateUpdate'
}
}
},
mounted() {
},
methods: {
}
}
</script>
<style>
</style>