Merge pull request #88 from jumpserver/feature-xpack-vault

Feature xpack vault
This commit is contained in:
Orange 2020-06-08 12:10:05 +08:00 committed by GitHub
commit 96dc3c36db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 95 additions and 21 deletions

View File

@ -151,6 +151,7 @@
"DateLastWeek": "最近一周",
"DateLastMonth": "最近一月",
"DateLast3Months": "最近三月",
"TestSuccessMsg": "测试成功",
"MFAConfirm": "MFA 认证",
"Yes": "是",
"No": "否",
@ -332,6 +333,7 @@
"Node": "节点",
"SystemUser": "系统用户",
"User": "用户",
"USER": "用户",
"UserGroups": "用户组",
"addAssetToThisPermission": "添加资产",
"addDatabaseAppToThisPermission": "添加数据库应用",

View File

@ -147,6 +147,7 @@
"CrontabHelpTips": "eg: Every Sunday 03:05 run <5 3 * * 0> <br>Tips:Using 5 digits linux crontab expressions<min hour day month week> (<a href='https://tool.lu/crontab/' target='_blank'>Online tools</a>) <br>Note:If both Regularly perform and Cycle perform are set,give priority to Regularly perform",
"BadRequestErrorMsg" : "Bad request, please check again",
"DateLast24Hours": "Last 24 hours",
"TestSuccessMsg": "Test Success",
"DateLastWeek": "Last week",
"DateLastMonth": "Last month",
"DateLast3Months": "Last 3 months",
@ -329,6 +330,7 @@
"Node": "Node",
"SystemUser": "System user",
"User": "User",
"USER": "User",
"UserGroups": "UserGroups",
"addAssetToThisPermission": "Add asset to this permission",
"addDatabaseAppToThisPermission": "Add DatabaseApp to this permission",

View File

@ -34,13 +34,13 @@ export default [
component: () => import('@/views/ops/CommandExecution'),
meta: { title: i18n.t('route.BatchCommand') }
},
{
path: 'celery/task/:id',
component: () => import('@/views/ops/CeleryTaskLog'),
name: 'CeleryTaskLog',
hidden: true,
meta: { title: i18n.t('route.CeleryTaskLog') }
},
// {
// path: 'celery/task/:id',
// component: () => import('@/views/ops/CeleryTaskLog'),
// name: 'CeleryTaskLog',
// hidden: true,
// meta: { title: i18n.t('route.CeleryTaskLog') }
// },
{
path: 'task/monitor',
name: 'TaskMonitor',

View File

@ -66,7 +66,14 @@ export default {
name: 'TestConnection',
title: this.$t('assets.TestConnection'),
callback: function(val) {
console.log(val)
if (!val.row.port) {
return this.$message.error(this.$t('common.BadRequestErrorMsg'))
}
this.$axios.post(`/api/v1/assets/gateways/${val.cellValue}/test-connective/`, { port: val.row.port }).then(
res => {
return this.$message.success(this.$t('common.TestSuccessMsg'))
}
)
}
}
]

View File

@ -55,7 +55,7 @@ export default {
this.$axios.put(
`/api/v1/xpack/change-auth-plan/plan-execution-subtask/${cellValue}/`,
).then(res => {
window.open(`/core/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
window.open(`/#/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
})
}.bind(this)
}

View File

@ -75,7 +75,7 @@ export default {
type: 'primary',
title: this.$t('xpack.ChangeAuthPlan.Log'),
callback: function({ cellValue, tableData }) {
window.open(`/core/ops/celery/task/${cellValue}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
window.open(`/#/ops/celery/task/${cellValue}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
}
},
{

View File

@ -40,7 +40,7 @@ export default {
`/api/v1/xpack/change-auth-plan/plan-execution/`,
{ plan: this.object.id }
).then(res => {
window.open(`/core/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
window.open(`/#/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
})
}.bind(this)
}

View File

@ -56,7 +56,7 @@ export default {
`/api/v1/xpack/change-auth-plan/plan-execution/`,
{ plan: data.cellValue }
).then(res => {
window.open(`/core/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
window.open(`/#/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
})
}.bind(this)
}

View File

@ -1,6 +1,28 @@
<template>
<div>
<GenericTreeListPage ref="TreeTablePage" :table-config="tableConfig" :header-actions="headerActions" :tree-setting="treeSetting" />
<Dialog width="25%" :title="this.$t('common.MFAConfirm')" :visible.sync="showMFADialog" :show-confirm="false" @cancel="handleMFAConfirm()">
<div v-if="MFAConfirmed">
<el-form label-position="right" label-width="80px" :model="MFAInfo">
<el-form-item :label="this.$t('assets.Hostname')">
<el-input v-model="MFAInfo.hostname" disabled />
</el-form-item>
<el-form-item :label="this.$t('assets.Username')">
<el-input v-model="MFAInfo.username" disabled />
</el-form-item>
<el-form-item :label="this.$t('assets.Password')">
<el-input v-model="MFAInfo.password" type="password" show-password />
</el-form-item>
</el-form>
</div>
<div v-else style="display: flex;justify-content:space-between;">
<div style="line-height: 34px;text-align: center">MFA</div>
<div style="width: 70%">
<el-input v-model="MFAInput" />
</div>
<el-button size="small" type="primary" @click="MFAConfirm">{{ this.$t('common.Confirm') }}</el-button>
</div>
</Dialog>
<Dialog width="50" :title="this.$t('assets.UpdateAssetUserToken')" :visible.sync="showDialog" @confirm="handleConfirm()" @cancel="handleCancel()">
<el-form label-position="right" label-width="80px" :model="dialogInfo">
<el-form-item :label="this.$t('assets.Hostname')">
@ -33,7 +55,16 @@ export default {
},
data() {
return {
MFAConfirmed: false,
MFAInput: '',
MFAInfo: {
asset: '',
username: '',
hostname: '',
password: ''
},
showDialog: false,
showMFADialog: false,
dialogInfo: {
asset: '',
username: '',
@ -93,6 +124,15 @@ export default {
hasDelete: false, // can set function(row, value)
canDelete: false,
extraActions: [
{
name: this.$t('common.View'),
title: this.$t('common.View'),
type: 'primary',
callback: function(val) {
this.MFAInfo.asset = val.cellValue
this.showMFADialog = true
}.bind(this)
},
{
name: 'delete',
title: this.$t('common.Delete'),
@ -109,10 +149,10 @@ export default {
callback: (val) => {
console.log(val.cellValue)
this.$axios.post(
`api/v1/assets/asset-users/tasks/?id=${val.cellValue}`,
`/api/v1/assets/asset-users/tasks/?id=${val.cellValue}`,
{ action: 'test' }
).then(res => {
window.open(`/core/ops/celery/task/${res.task}/log/`, '', 'width=900,height=600')
window.open(`/#/ops/celery/task/${res.task}/log/`, '', 'width=900,height=600')
})
}
},
@ -126,13 +166,6 @@ export default {
this.dialogInfo.hostname = val.row.hostname
this.dialogInfo.username = val.row.username
}.bind(this)
},
{
name: 'Push',
title: this.$t('common.Push'),
callback: function(val) {
console.log('Push')
}
}
]
}
@ -142,6 +175,36 @@ export default {
}
},
methods: {
MFAConfirm() {
if (this.MFAInput.length !== 6) {
return this.$message.error(this.$t('common.updateErrorMsg'))
}
this.$axios.post(
`/api/v1/authentication/otp/verify/`, {
code: this.MFAInput
}
).then(
res => {
this.$axios.get(`/api/v1/assets/asset-user-auth-infos/${this.MFAInfo.asset}/`).then(res => {
this.MFAConfirmed = true
this.MFAInfo.hostname = res.hostname
this.MFAInfo.password = res.password
this.MFAInfo.username = res.username
})
}
)
},
handleMFAConfirm() {
this.MFAInfo = {
asset: '',
username: '',
hostname: '',
password: ''
}
this.MFAInput = ''
this.showMFADialog = false
this.MFAConfirmed = false
},
handleCancel() {
this.dialogInfo = {
asset: '',