Skip to content

Commit d95ac6f

Browse files
authored
fix(entities-vaults): mask token and app role seceret id fields in vault detail page (#2583)
* fix(entities-vaults): mask token and app role seceret id fields in vault detail page * fix(entities-vaults): simplify the implementation according to suggestion
1 parent 66c72e1 commit d95ac6f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/entities/entities-vaults/src/components/VaultConfigCard.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,20 @@
1010
@fetch:error="(err: any) => $emit('fetch:error', err)"
1111
@fetch:success="(entity: any) => $emit('fetch:success', entity)"
1212
@loading="(val: boolean) => $emit('loading', val)"
13-
/>
13+
>
14+
<template #config="{ rowValue }">
15+
<ConfigCardItem
16+
v-for="propKey in Object.keys(rowValue)"
17+
:key="propKey"
18+
:item="{
19+
key: propKey,
20+
value: getPropValue(propKey, rowValue),
21+
label: getMetadataLabel(propKey),
22+
type: (propKey === 'token' || propKey === 'approle_secret_id') ? ConfigurationSchemaType.Redacted : ConfigurationSchemaType.Text,
23+
}"
24+
/>
25+
</template>
26+
</EntityBaseConfigCard>
1427
</div>
1528
</template>
1629

@@ -19,7 +32,10 @@ import {
1932
EntityBaseConfigCard,
2033
ConfigurationSchemaSection,
2134
ConfigurationSchemaType,
35+
ConfigCardItem,
2236
SupportedEntityType,
37+
useStringHelpers,
38+
useHelpers,
2339
} from '@kong-ui-public/entities-shared'
2440
import type { AxiosError } from 'axios'
2541
import type { PropType } from 'vue'
@@ -69,6 +85,8 @@ const props = defineProps({
6985
const fetchUrl = computed((): string => endpoints.form[props.config?.app]?.edit)
7086
7187
const { i18n: { t } } = composables.useI18n()
88+
const { convertKeyToTitle } = useStringHelpers()
89+
const { getPropValue } = useHelpers()
7290
7391
const configSchema = ref<VaultConfigurationSchema>({
7492
id: {},
@@ -93,4 +111,8 @@ const configSchema = ref<VaultConfigurationSchema>({
93111
type: ConfigurationSchemaType.Json,
94112
},
95113
})
114+
115+
const getMetadataLabel = (propKey: string) => {
116+
return configSchema.value?.[propKey as keyof typeof configSchema.value]?.label || convertKeyToTitle(propKey)
117+
}
96118
</script>

0 commit comments

Comments
 (0)