From 4a9a9058b6e02b6a290bb8025b47a1bfd0894827 Mon Sep 17 00:00:00 2001 From: halo Date: Tue, 5 Nov 2024 10:57:29 +0800 Subject: [PATCH] feat: azure key vault --- src/views/settings/Feature/Vault/Azure.vue | 61 ++++++++++++++++++ src/views/settings/Feature/Vault/Base.vue | 63 ++++++++++++++++++ src/views/settings/Feature/Vault/HCP.vue | 64 +++++++++++++++++++ .../Feature/{Vault.vue => Vault/index.vue} | 53 +++++---------- src/views/settings/Feature/index.vue | 2 +- 5 files changed, 205 insertions(+), 38 deletions(-) create mode 100644 src/views/settings/Feature/Vault/Azure.vue create mode 100644 src/views/settings/Feature/Vault/Base.vue create mode 100644 src/views/settings/Feature/Vault/HCP.vue rename src/views/settings/Feature/{Vault.vue => Vault/index.vue} (58%) diff --git a/src/views/settings/Feature/Vault/Azure.vue b/src/views/settings/Feature/Vault/Azure.vue new file mode 100644 index 000000000..08e849f15 --- /dev/null +++ b/src/views/settings/Feature/Vault/Azure.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/views/settings/Feature/Vault/Base.vue b/src/views/settings/Feature/Vault/Base.vue new file mode 100644 index 000000000..281eb010f --- /dev/null +++ b/src/views/settings/Feature/Vault/Base.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/settings/Feature/Vault/HCP.vue b/src/views/settings/Feature/Vault/HCP.vue new file mode 100644 index 000000000..724720a6c --- /dev/null +++ b/src/views/settings/Feature/Vault/HCP.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/src/views/settings/Feature/Vault.vue b/src/views/settings/Feature/Vault/index.vue similarity index 58% rename from src/views/settings/Feature/Vault.vue rename to src/views/settings/Feature/Vault/index.vue index 1ccd7e0d9..ff4abd9ce 100644 --- a/src/views/settings/Feature/Vault.vue +++ b/src/views/settings/Feature/Vault/index.vue @@ -12,6 +12,8 @@ import { GenericCreateUpdateForm } from '@/layout/components' import IBox from '@/components/IBox/index.vue' import { openTaskPage } from '@/utils/jms' import store from '@/store' +import HashiCorpKV from './HCP.vue' +import AzureKV from './Azure.vue' export default { components: { @@ -25,24 +27,6 @@ export default { hasReset: false, helpText: this.$t('VaultHelpText'), moreButtons: [ - { - title: this.$t('Test'), - loading: false, - disabled: !store.getters.publicSettings['VAULT_ENABLED'], - callback: function(value, form, btn) { - btn.loading = true - vm.$axios.post( - '/api/v1/settings/vault/testing/', - value - ).then(res => { - vm.$message.success(res['msg']) - }).catch(() => { - vm.$log.error('err occur') - }).finally(() => { - btn.loading = false - }) - } - }, { title: this.$t('Sync'), loading: false, @@ -62,17 +46,9 @@ export default { } } ], - encryptedFields: ['VAULT_HCP_TOKEN'], fields: [ - [this.$t('Backend'), - [ - 'VAULT_ENABLED', - 'VAULT_HCP_HOST', - 'VAULT_HCP_TOKEN', - 'VAULT_HCP_MOUNT_POINT' - ] - ], - [this.$t('History'), ['HISTORY_ACCOUNT_CLEAN_LIMIT']] + [this.$t('Basic'), ['VAULT_ENABLED', 'VAULT_BACKEND', 'HISTORY_ACCOUNT_CLEAN_LIMIT']], + [this.$t('Provider'), ['HCP', 'AZURE']] ], fieldsMeta: { HISTORY_ACCOUNT_CLEAN_LIMIT: { @@ -83,21 +59,24 @@ export default { VAULT_ENABLED: { disabled: true }, - VAULT_HCP_HOST: { + VAULT_BACKEND: { + label: this.$t('Provider'), hidden: (formValue) => { return !formValue.VAULT_ENABLED } }, - VAULT_HCP_TOKEN: { - hidden: (formValue) => { - return !formValue.VAULT_ENABLED + HCP: { + label: this.$t('HashicorpVault'), + component: HashiCorpKV, + hidden: (form) => { + return form['VAULT_BACKEND'] !== 'hcp' } }, - VAULT_HCP_MOUNT_POINT: { - helpText: this.$t('VaultHCPMountPoint'), - helpTextAsTip: true, - hidden: (formValue) => { - return !formValue.VAULT_ENABLED + AZURE: { + label: this.$t('AzureKeyVault'), + component: AzureKV, + hidden: (form) => { + return form['VAULT_BACKEND'] !== 'azure' } } }, diff --git a/src/views/settings/Feature/index.vue b/src/views/settings/Feature/index.vue index 58d4980ce..cbf1a4150 100644 --- a/src/views/settings/Feature/index.vue +++ b/src/views/settings/Feature/index.vue @@ -9,7 +9,7 @@