Skip to content

Commit

Permalink
Merge branch 'pam' of github.com:jumpserver/lina into pam
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Jan 3, 2025
2 parents 9f47b50 + 5022ca9 commit 572e610
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 47 deletions.
53 changes: 49 additions & 4 deletions src/components/Apps/AccountCreateUpdateForm/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSettin

export const accountFieldsMeta = (vm) => {
const defaultPrivilegedAccounts = ['root', 'administrator']

const isPam = vm.$route.query.flag === 'copy' || vm.$route.query.flag === 'move'

return {
assets: {
component: Select2,
Expand All @@ -27,6 +30,7 @@ export const accountFieldsMeta = (vm) => {
component: Select2,
rules: [Required],
el: {
disabled: isPam,
multiple: false,
ajax: {
url: '/api/v1/accounts/account-templates/',
Expand All @@ -43,13 +47,19 @@ export const accountFieldsMeta = (vm) => {
rules: [Required],
label: vm.$t('AccountPolicy'),
helpTip: vm.$t('AccountPolicyHelpText'),
el: {
disabled: isPam
},
hidden: () => {
return vm.platform || vm.asset
}
},
name: {
label: vm.$t('Name'),
rules: [RequiredChange],
el: {
disabled: isPam
},
on: {
input: ([value], updateForm) => {
if (!vm.usernameChanged) {
Expand All @@ -66,7 +76,7 @@ export const accountFieldsMeta = (vm) => {
},
username: {
el: {
disabled: !!vm.account?.name
disabled: !!vm.account?.name || isPam
},
on: {
input: ([value], updateForm) => {
Expand All @@ -85,6 +95,9 @@ export const accountFieldsMeta = (vm) => {
},
privileged: {
label: vm.$t('Privileged'),
el: {
disabled: isPam
},
hidden: () => {
return vm.addTemplate
}
Expand All @@ -97,6 +110,7 @@ export const accountFieldsMeta = (vm) => {
el: {
multiple: false,
clearable: true,
disabled: isPam,
ajax: {
url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`,
transformOption: (item) => {
Expand All @@ -107,6 +121,7 @@ export const accountFieldsMeta = (vm) => {
},
su_from_username: {
label: vm.$t('UserSwitchFrom'),
disabled: isPam,
hidden: (formValue) => {
return vm.platform || vm.asset || vm.addTemplate
}
Expand All @@ -115,39 +130,57 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('Password'),
component: UpdateToken,
hidden: (formValue) => {
return formValue.secret_type !== 'password' || vm.addTemplate
return formValue.secret_type !== 'password' || vm.addTemplate || vm.$route.fullPath.includes('pam')
}
},
ssh_key: {
label: vm.$t('PrivateKey'),
component: UploadSecret,
el: {
disabled: isPam
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
passphrase: {
label: vm.$t('Passphrase'),
component: UpdateToken,
el: {
disabled: isPam
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
token: {
label: vm.$t('Token'),
component: UploadSecret,
el: {
disabled: isPam
},
hidden: (formValue) => formValue.secret_type !== 'token' || vm.addTemplate
},
access_key: {
id: 'access_key',
label: vm.$t('AccessKey'),
component: UploadSecret,
el: {
disabled: isPam
},
hidden: (formValue) => formValue.secret_type !== 'access_key' || vm.addTemplate
},
api_key: {
id: 'api_key',
label: vm.$t('ApiKey'),
component: UploadSecret,
el: {
disabled: isPam
},
hidden: (formValue) => formValue.secret_type !== 'api_key' || vm.addTemplate
},
secret_type: {
type: 'radio-group',
options: [],
el: {
disabled: isPam
},
hidden: () => {
return vm.addTemplate
}
Expand Down Expand Up @@ -182,10 +215,22 @@ export const accountFieldsMeta = (vm) => {
}
},
is_active: {
label: vm.$t('IsActive')
label: vm.$t('IsActive'),
el: {
disabled: isPam
}
},
comment: {
label: vm.$t('Comment')
label: vm.$t('Comment'),
el: {
disabled: isPam
}
},
secret_reset: {
label: vm.$t('SecretReset'),
el: {
disabled: isPam
}
}
}
}
40 changes: 28 additions & 12 deletions src/components/Apps/AccountListTable/AccountCreateUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:title="title"
:visible="iVisible"
class="drawer"
@close-drawer="iVisible = false"
@close-drawer="handleCloseDrawer"
>
<Page :title="'null'">
<IBox class="content">
Expand Down Expand Up @@ -109,18 +109,27 @@ export default {
}
}).catch(error => {
this.iVisible = true
console.log(this.iVisible)
console.log(this.origin)
this.handleResult(null, error)
})
},
editAccount(form) {
const data = { ...form }
this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, data).then(() => {
this.iVisible = false
this.$emit('add', true)
this.$message.success(this.$tc('UpdateSuccessMsg'))
}).catch(error => this.setFieldError(error))
const flag = this.$route.query.flag
switch (flag) {
case 'copy':
this.handleAccountOperation(this.account.id, 'copy-to-assets', data)
break
case 'move':
this.handleAccountOperation(this.account.id, 'move-to-assets', data)
break
default:
this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, data).then(() => {
this.iVisible = false
this.$emit('add', true)
this.$message.success(this.$tc('UpdateSuccessMsg'))
}).catch(error => this.setFieldError(error))
}
},
handleResult(resp, error) {
let bulkCreate = !this.asset
Expand Down Expand Up @@ -173,6 +182,17 @@ export default {
refsAutoDataForm.setFieldError(current, err)
}
}
},
handleCloseDrawer() {
this.iVisible = false
Reflect.deleteProperty(this.$route.query, 'flag')
},
handleAccountOperation(id, path, data) {
this.$axios.post(`/api/v1/accounts/accounts/${id}/${path}/`, data).then((res) => {
this.iVisible = false
this.$emit('add', true)
this.handleResult(res, null)
}).catch(error => this.handleResult(null, error))
}
}
}
Expand All @@ -187,8 +207,4 @@ export default {
}
}
}
.content {
}
</style>
69 changes: 50 additions & 19 deletions src/components/Apps/AccountListTable/AccountList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,28 @@
v-bind="updateSelectedDialogSetting"
@update="handleAccountBulkUpdate"
/>
<PasswordHistoryDialog
v-if="showPasswordHistoryDialog"
:account="currentAccountColumn"
:visible.sync="showPasswordHistoryDialog"
/>
</div>
</template>

<script>
import ListTable from '@/components/Table/DrawerListTable/index.vue'
import { ActionsFormatter, PlatformFormatter, SecretViewerFormatter } from '@/components/Table/TableFormatters'
import ViewSecret from './ViewSecret.vue'
import UpdateSecretInfo from './UpdateSecretInfo.vue'
import AccountCreateUpdate from './AccountCreateUpdate.vue'
import { connectivityMeta } from './const'
import { openTaskPage } from '@/utils/jms'
import {
ActionsFormatter,
PlatformFormatter,
SecretViewerFormatter
} from '@/components/Table/TableFormatters'
import ViewSecret from './ViewSecret.vue'
import UpdateSecretInfo from './UpdateSecretInfo.vue'
import ResultDialog from './BulkCreateResultDialog.vue'
import AccountCreateUpdate from './AccountCreateUpdate.vue'
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
import ListTable from '@/components/Table/DrawerListTable/index.vue'
import AccountBulkUpdateDialog from '@/components/Apps/AccountListTable/AccountBulkUpdateDialog.vue'
export default {
Expand All @@ -72,7 +82,8 @@ export default {
ListTable,
UpdateSecretInfo,
ViewSecret,
AccountCreateUpdate
AccountCreateUpdate,
PasswordHistoryDialog
},
props: {
url: {
Expand Down Expand Up @@ -119,8 +130,7 @@ export default {
},
columnsMeta: {
type: Object,
default: () => {
}
default: () => {}
},
columnsDefault: {
type: Array,
Expand All @@ -140,6 +150,8 @@ export default {
data() {
const vm = this
return {
currentAccountColumn: {},
showPasswordHistoryDialog: false,
showViewSecretDialog: false,
showUpdateSecretDialog: false,
showResultDialog: false,
Expand Down Expand Up @@ -323,14 +335,14 @@ export default {
return (
<span className='connect'>
<el-button type='primary' size='mini' plain>
<i className='fa fa-desktop'/>
<i className='fa fa-desktop' />
</el-button>
</span>
)
}
},
asset: {
formatter: (row) => {
formatter: row => {
const to = {
name: 'AssetDetail',
params: { id: row.asset.id }
Expand Down Expand Up @@ -451,18 +463,39 @@ export default {
},
{
name: 'SecretHistory',
title: '密文历史'
// 密文历史
title: this.$t('SecretHistory'),
can: () => this.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
this.currentAccountColumn = row
this.$nextTick(() => {
this.showPasswordHistoryDialog = true
})
}
},
{
name: 'CopyToOther',
title: '复制到其他资产',
type: 'primary',
divided: true
divided: true,
callback: ({ row }) => {
vm.$route.query.flag = 'copy'
vm.iAsset = this.asset
vm.account = row
vm.showAddDialog = true
}
},
{
name: 'MoveToOther',
title: '移动到其他资产',
type: 'primary'
type: 'primary',
callback: ({ row }) => {
vm.$route.query.flag = 'move'
vm.iAsset = this.asset
vm.account = row
vm.showAddDialog = true
}
},
{
name: 'Clone',
Expand Down Expand Up @@ -500,8 +533,7 @@ export default {
can: () => {
return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
},
callback: async() => {
await this.getAssetDetail()
callback: () => {
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
Expand All @@ -516,8 +548,7 @@ export default {
can: () => {
return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
},
callback: async() => {
await this.getAssetDetail()
callback: () => {
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
Expand Down Expand Up @@ -654,6 +685,7 @@ export default {
Object.assign(this.account, account)
},
addAccountSuccess() {
Reflect.deleteProperty(this.$route.query, 'flag')
this.$refs.ListTable.reloadTable()
},
async getAssetDetail() {
Expand Down Expand Up @@ -692,9 +724,8 @@ export default {
}
</script>

<style lang='scss' scoped>
<style lang="scss" scoped>
.cell a {
color: var(--color-info);
}
</style>
Loading

0 comments on commit 572e610

Please sign in to comment.