Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip committed Dec 10, 2024
1 parent 8810dfb commit 4549c1c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 55 deletions.
51 changes: 22 additions & 29 deletions ui/app/components/secret-engine/configuration-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,27 @@
SPDX-License-Identifier: BUSL-1.1
~}}

{{#if @configModels.length}}
{{#each @configModels as |configModel|}}
{{#each configModel.displayAttrs as |attr|}}
{{! public key while not sensitive when editing/creating, should be hidden by default on viewing }}
{{#if (or attr.options.sensitive (eq attr.name "publicKey"))}}
<InfoTableRow
alwaysRender={{not (is-empty-value (get configModel attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{get configModel (or attr.options.fieldValue attr.name)}}
>
{{#if (or attr.options.sensitive (eq attr.name "publicKey"))}}
<MaskedInput
@value={{get configModel attr.name}}
@name={{attr.name}}
@displayOnly={{true}}
@allowCopy={{true}}
/>
{{/if}}
</InfoTableRow>
{{else}}
<InfoTableRow
@alwaysRender={{not (is-empty-value (get @model attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{get configModel (or attr.options.fieldValue attr.name)}}
@formatTtl={{eq attr.options.editType "ttl"}}
/>
{{/if}}
{{/each}}
{{#each @configModels as |configModel|}}
{{#each configModel.displayAttrs as |attr|}}
{{! public key while not sensitive when editing/creating, should be hidden by default on viewing }}
{{#if (or attr.options.sensitive (eq attr.name "publicKey"))}}
<InfoTableRow
alwaysRender={{not (is-empty-value (get configModel attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{get configModel (or attr.options.fieldValue attr.name)}}
>
{{#if (or attr.options.sensitive (eq attr.name "publicKey"))}}
<MaskedInput @value={{get configModel attr.name}} @name={{attr.name}} @displayOnly={{true}} @allowCopy={{true}} />
{{/if}}
</InfoTableRow>
{{else}}
<InfoTableRow
@alwaysRender={{not (is-empty-value (get @model attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{get configModel (or attr.options.fieldValue attr.name)}}
@formatTtl={{eq attr.options.editType "ttl"}}
/>
{{/if}}
{{/each}}
{{else}}
{{! Prompt user to configure the secret engine }}
Expand All @@ -50,4 +43,4 @@
/>
{{/unless}}
</EmptyState>
{{/if}}
{{/each}}
4 changes: 2 additions & 2 deletions ui/app/helpers/mountable-secret-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ export function mountableEngines() {
return MOUNTABLE_SECRET_ENGINES.slice();
}
// secret engines that have not other views than the mount view and mount details view
export const UN_SUPPORTED_ENGINES = ['alicloud', 'consul', 'gcp', 'gcpkms', 'nomad', 'rabbitmq', 'totp'];
export const UNSUPPORTED_ENGINES = ['alicloud', 'consul', 'gcp', 'gcpkms', 'nomad', 'rabbitmq', 'totp'];

export function unSupportedEngines() {
return UN_SUPPORTED_ENGINES.slice();
return UNSUPPORTED_ENGINES.slice();
}

export function allEngines() {
Expand Down
22 changes: 8 additions & 14 deletions ui/app/routes/vault/cluster/secrets/backend/configuration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,17 @@ export default class SecretsBackendConfigurationRoute extends Route {

async fetchAzureConfig(id) {
try {
let azureModel = await this.store.queryRecord('azure/config', { backend: id });
const azureModel = await this.store.queryRecord('azure/config', { backend: id });
let issuer = null;
if (azureModel.isConfigured) {
if (this.version.isEnterprise) {
// Issuer is an enterprise only related feature
// Issuer is also a global endpoint that doesn't mean anything in the Azure secret details context if WIF related fields on the azureConfig have not been set.
const WIF_FIELDS = ['identityTokenAudience', 'identityTokenTtl'];
WIF_FIELDS.some((field) => azureModel[field]) ? (issuer = await this.fetchIssuer()) : null;
}
} else {
// azure will return a 200 if the config is set or not set.
// thus, we set the model to null if no params have been configured.
azureModel = null;
if (this.version.isEnterprise) {
// Issuer is an enterprise only related feature
// Issuer is also a global endpoint that doesn't mean anything in the Azure secret details context if WIF related fields on the azureConfig have not been set.
const WIF_FIELDS = ['identityTokenAudience', 'identityTokenTtl'];
WIF_FIELDS.some((field) => azureModel[field]) ? (issuer = await this.fetchIssuer()) : null;
}

const configArray = [];
configArray.push(azureModel, issuer);
if (azureModel.isConfigured) configArray.push(azureModel);
if (issuer) configArray.push(issuer);
return configArray;
} catch (e) {
if (e.httpStatus === 404) {
Expand Down
7 changes: 0 additions & 7 deletions ui/app/serializers/azure/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export default class AzureConfigSerializer extends ApplicationSerializer {
if (!payload.data) {
return super.normalizeResponse(...arguments);
}
// remove rootPasswordTtl and identityTokenTtl if the API's default value of 0. We don't want to display this value on configuration details if they haven't changed the default value
if (payload.data.root_password_ttl === 0) {
delete payload.data.root_password_ttl;
}
if (payload.data.identity_token_ttl === 0) {
delete payload.data.identity_token_ttl;
}

const normalizedPayload = {
id: payload.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@configModels={{this.model.configModels}}
@typeDisplay={{this.typeDisplay}}
@id={{this.modelId}}
@formatTtl={{this.formatTtl}}
/>

<SecretsEngineMountConfig
Expand Down
4 changes: 2 additions & 2 deletions ui/tests/acceptance/secrets/backend/engines-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { v4 as uuidv4 } from 'uuid';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import { UN_SUPPORTED_ENGINES, mountableEngines } from 'vault/helpers/mountable-secret-engines';
import { UNSUPPORTED_ENGINES, mountableEngines } from 'vault/helpers/mountable-secret-engines';
import { PAGE } from 'vault/tests/helpers/kv/kv-selectors';

const SELECTORS = {
Expand Down Expand Up @@ -56,7 +56,7 @@ module('Acceptance | secret-engine list view', function (hooks) {
await visit('/vault/cluster/dashboard');
await visit('/vault/secrets');

if (UN_SUPPORTED_ENGINES.includes(engine)) {
if (UNSUPPORTED_ENGINES.includes(engine)) {
assert
.dom(PAGE.backends.link(enginePath))
.doesNotHaveClass(
Expand Down

0 comments on commit 4549c1c

Please sign in to comment.