Skip to content

Commit 1a8c69b

Browse files
authored
feat(vault-form): add STS endpoint url in AWS vault form [KM-297] (#1515)
* feat(vault-form): add STS endpoint url in AWS vault form [KM-297] * docs(vault-form.md): add an entry to doc [KM-297] add an entry of awsStsEndpointUrlAvailable to doc * refactor(vaultform): formatting and field value intialization [KM-297] formatting and adding sts_endpoint_url in originalConfigFields
1 parent 73f124e commit 1a8c69b

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

packages/entities/entities-vaults/docs/vault-form.md

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ A form component for Vaults.
9191
- required: `false`
9292
- default: `undefined`
9393
- Show/hide approle option and corresponding fields.
94+
95+
- `awsStsEndpointUrlAvailable`
96+
- type: `boolean`
97+
- required: `false`
98+
- default: `undefined`
99+
- Show/hide STS endpoint url field in AWS Vault Config.
94100

95101
The base konnect or kongManger config.
96102

packages/entities/entities-vaults/sandbox/pages/VaultFormPage.vue

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const kongManagerConfig = ref<KongManagerVaultFormConfig>({
5454
azureVaultProviderAvailable: false,
5555
ttl: true,
5656
hcvAppRoleMethodAvailable: true,
57+
awsStsEndpointUrlAvailable: true,
5758
})
5859
5960
const onError = (error: AxiosError) => {

packages/entities/entities-vaults/src/components/VaultForm.cy.ts

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const baseConfigKM: KongManagerVaultFormConfig = {
3232
cancelRoute,
3333
azureVaultProviderAvailable: false,
3434
ttl: true,
35+
awsStsEndpointUrlAvailable: true,
3536
}
3637

3738
const baseConfigKMTurnOffTTL: KongManagerVaultFormConfig = {
@@ -108,6 +109,7 @@ describe('<VaultForm />', () => {
108109
cy.getTestId('provider-select').click({ force: true })
109110
cy.getTestId('vault-form-provider-aws').click({ force: true })
110111
cy.getTestId('vault-form-config-aws-region').should('be.visible')
112+
cy.getTestId('vault-form-config-aws-sts_endpoint_url').should('be.visible')
111113
cy.getTestId('advanced-fields-collapse').should('be.visible')
112114

113115
// form fields - gcp
@@ -169,6 +171,7 @@ describe('<VaultForm />', () => {
169171
cy.getTestId('provider-select').click({ force: true })
170172
cy.getTestId('vault-form-provider-aws').click({ force: true })
171173
cy.getTestId('vault-form-config-aws-region').should('be.visible')
174+
cy.getTestId('vault-form-config-aws-sts_endpoint_url').should('not.exist')
172175
cy.getTestId('advanced-fields-collapse').should('not.exist')
173176

174177
// form fields - gcp

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

+18-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@
128128
required
129129
type="text"
130130
/>
131+
<KInput
132+
v-if="config.awsStsEndpointUrlAvailable"
133+
v-model.trim="configFields[VaultProviders.AWS].sts_endpoint_url"
134+
autocomplete="off"
135+
data-testid="vault-form-config-aws-sts_endpoint_url"
136+
:is-readonly="form.isReadonly"
137+
:label="t('form.config.aws.fields.sts_endpoint_url.label')"
138+
:label-attributes="{
139+
info: t('form.config.aws.fields.sts_endpoint_url.tooltip'),
140+
tooltipAttributes: { maxWidth: '400px' },
141+
}"
142+
type="text"
143+
/>
131144
</div>
132145

133146
<!-- GCP fields -->
@@ -627,6 +640,7 @@ const configFields = reactive<ConfigFields>({
627640
endpoint_url: '',
628641
assume_role_arn: '',
629642
role_session_name: 'KongVault',
643+
sts_endpoint_url: '',
630644
} as AWSVaultConfig,
631645
[VaultProviders.GCP]: {
632646
project_id: '',
@@ -669,6 +683,7 @@ const originalConfigFields = reactive<ConfigFields>({
669683
endpoint_url: '',
670684
assume_role_arn: '',
671685
role_session_name: 'KongVault',
686+
sts_endpoint_url: '',
672687
} as AWSVaultConfig,
673688
[VaultProviders.GCP]: {
674689
project_id: '',
@@ -871,8 +886,8 @@ const isVaultConfigValid = computed((): boolean => {
871886
// AWS Vault fields logic
872887
if (vaultProvider.value === VaultProviders.AWS) {
873888
return !Object.keys(configFields[VaultProviders.AWS]).filter(key => {
874-
// endpoint_url, assume_role_arn and ttl fields are optional
875-
if (['endpoint_url', 'assume_role_arn', 'ttl', 'neg_ttl', 'resurrect_ttl'].includes(key)) {
889+
// sts_endpoint_url, endpoint_url, assume_role_arn and ttl fields are optional
890+
if (['endpoint_url', 'assume_role_arn', 'ttl', 'neg_ttl', 'resurrect_ttl', 'sts_endpoint_url'].includes(key)) {
876891
return false
877892
}
878893
return !(configFields[vaultProvider.value] as AWSVaultConfig)[key as keyof AWSVaultConfig]
@@ -949,6 +964,7 @@ const getPayload = computed((): Record<string, any> => {
949964
...configFields[vaultProvider.value],
950965
endpoint_url: (configFields[vaultProvider.value] as AWSVaultConfig).endpoint_url || null,
951966
assume_role_arn: (configFields[vaultProvider.value] as AWSVaultConfig).assume_role_arn || null,
967+
sts_endpoint_url: (configFields[vaultProvider.value] as AWSVaultConfig).sts_endpoint_url || null,
952968
}
953969
954970
let config: VaultPayload['config'] = configFields[vaultProvider.value]

packages/entities/entities-vaults/src/locales/en.json

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@
219219
"role_session_name": {
220220
"label": "Role Session Name",
221221
"tooltip": "The role session name used for role assuming."
222+
},
223+
"sts_endpoint_url": {
224+
"label": "STS Endpoint URL",
225+
"tooltip": "The custom STS endpoint URL used for role assuming in AWS Vault. Note that this value will override the default STS endpoint URL(which should be `https: //sts.amazonaws.com`, or `https: //sts.<region>.amazonaws.com` if you have `AWS_STS_REGIONAL_ENDPOINTS` set to `regional`). If you are not using private VPC endpoint for STS service, you should not specify this value."
222226
}
223227
}
224228
},

packages/entities/entities-vaults/src/types/vault-form.ts

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export interface BaseVaultFormConfig extends Omit<BaseFormConfig, 'cancelRoute'>
2323
* Show/hide Konnect Config Store option
2424
*/
2525
konnectConfigStoreAvailable?: boolean
26+
/**
27+
* Show/hide AWS StsEndpointUrl field
28+
*/
29+
awsStsEndpointUrlAvailable?: boolean
2630
}
2731

2832
/** Konnect Vault form config */
@@ -60,6 +64,7 @@ export interface AWSVaultConfig {
6064
ttl?: number
6165
neg_ttl?: number
6266
resurrect_ttl?: number
67+
sts_endpoint_url?: string
6368
}
6469

6570
export interface GCPVaultConfig {

0 commit comments

Comments
 (0)