mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-19 13:41:10 +02:00
* UI: Implement overview page for KV v2 (#28162) * build json editor patch form * finish patch component and tests * add tab to each route * and path route * add overview tab to tests * update overview to use updated_time instead of created_time * redirect relevant secret.details to secret.index * compute secretState in component instead of pass as arg * add capabilities service * add error handling to fetchSubkeys adapter request * add overview tabs to test * add subtext to overview card * remaining redirects in secret edit * remove create new version from popup menu * fix breadcrumbs for overview * separate adding capabilities service * add service to kv engine * Revert "separate adding capabilities service" This reverts commit bb70b12ab7dbcde0fbd2d4d81768e5c8b1c420cc. * Revert "add service to kv engine" This reverts commit bfa880535ef7d529d7610936b2c1aae55673d23f. * update navigation test * consistently navigate to secret.index route to be explicit * finish overview navigation tests * add copyright header * update delete tests * fix nav testrs * cleanup secret edit redirects * remove redundant async/awaits * fix create test * edge case tests * secret acceptance tests * final component tests * rename kvSecretDetails external route to kvSecretOverview * add comment * UI: Add patch route and implement Page::Secret::Patch page component (sidebranch) (#28192) * add tab to each route * and path route * add overview tab to tests * update overview to use updated_time instead of created_time * redirect relevant secret.details to secret.index * compute secretState in component instead of pass as arg * add capabilities service * add error handling to fetchSubkeys adapter request * add patch route and put in page component * add patch secret action to subkeys card * fix component name * add patch capability * alphabetize computed capabilities * update links, cleanup selectors * fix more merge conflict stuff * add capabilities test * add models to patch link * add test for patch route * rename external route * add error templates * make notes about enterprise tests, filter one * remove errors, transition (redirect) instead * redirect patch routes * UI: Move fetching secret data to child route (#28198) * remove @secret from metadata details * use metadata model instead of secret in paths page * put delete back into kv/data adapter * grant access in control group test * update metadata route and permissions * remove secret from parent route, only fetch in details route * change more permissions to route perms, add tests * revert overview redirect from list view * wrap model in conditional for perms * remove redundant canReadCustomMetadata check * rename adapter method * handle overview 404 * remove comment * add customMetadata as an arg * update grantAccess in test * make version param easier to follow * VAULT-30494 handle 404 jira * refactor capabilities to return an object * update create tests * add test for default truthy capabilities * remove destroy-all-versions from kv/data adapter * UI: Add enterprise checks (#28215) * add enterprise check for subkey card * add max height and scroll to subkey card * only fetch subkeys if enterprise * remove check in overview * add test * Update ui/tests/integration/components/kv/page/kv-page-overview-test.js * fix test failures (#28222) * add assertion * add optional chaining * create/delete versioned secret in each module * wait for transition * add another waitUntil * UI: Add patch latest version to toolbar (#28223) * add patch latest version action to toolbar * make isPatchAllowed arg all encompassing * no longer need model check * use hash so both promises fire at the same time * add subkeys to policy * Update ui/lib/kv/addon/routes/secret.js * add changelog * small cleanup items! (#28229) * add conditional for enterprise checking tabs * cleanup fetchMultiplePaths method * add test * remove todo comment, ticket created and design wants to hold off * keep transition, update comments * cleanup tests, add index to breadcrumbs * add some test coverage * toggle so value is readable
159 lines
4.7 KiB
JavaScript
159 lines
4.7 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { service } from '@ember/service';
|
|
import { pathIsDirectory } from 'kv/utils/kv-breadcrumbs';
|
|
/**
|
|
* @module DashboardQuickActionsCard
|
|
* DashboardQuickActionsCard component allows users to see a list of secrets engines filtered by
|
|
* kv, pki and database and perform certain actions based on the type of secret engine selected
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <Dashboard::QuickActionsCard @secretsEngines={{@model.secretsEngines}} />
|
|
* ```
|
|
*/
|
|
|
|
const QUICK_ACTION_ENGINES = ['pki', 'database'];
|
|
|
|
export default class DashboardQuickActionsCard extends Component {
|
|
@service router;
|
|
|
|
@tracked selectedEngine;
|
|
@tracked selectedAction;
|
|
@tracked paramValue;
|
|
|
|
get actionOptions() {
|
|
switch (this.selectedEngine.type) {
|
|
case 'kv':
|
|
return ['Find KV secrets'];
|
|
case 'database':
|
|
return ['Generate credentials for database'];
|
|
case 'pki':
|
|
return ['Issue certificate', 'View certificate', 'View issuer'];
|
|
default:
|
|
return [];
|
|
}
|
|
}
|
|
|
|
get searchSelectParams() {
|
|
switch (this.selectedAction) {
|
|
case 'Find KV secrets':
|
|
return {
|
|
title: 'Secret path',
|
|
subText: 'Path of the secret you want to read.',
|
|
buttonText: 'Read secrets',
|
|
model: 'kv/metadata',
|
|
route: 'vault.cluster.secrets.backend.kv.secret.index',
|
|
nameKey: 'path',
|
|
queryObject: { pathToSecret: '', backend: this.selectedEngine.id },
|
|
objectKeys: ['path', 'id'],
|
|
};
|
|
case 'Generate credentials for database':
|
|
return {
|
|
title: 'Role to use',
|
|
buttonText: 'Generate credentials',
|
|
model: 'database/role',
|
|
route: 'vault.cluster.secrets.backend.credentials',
|
|
queryObject: { backend: this.selectedEngine.id },
|
|
};
|
|
case 'Issue certificate':
|
|
return {
|
|
title: 'Role to use',
|
|
placeholder: 'Type to find a role',
|
|
buttonText: 'Issue leaf certificate',
|
|
model: 'pki/role',
|
|
route: 'vault.cluster.secrets.backend.pki.roles.role.generate',
|
|
queryObject: { backend: this.selectedEngine.id },
|
|
};
|
|
case 'View certificate':
|
|
return {
|
|
title: 'Certificate serial number',
|
|
placeholder: '33:a3:...',
|
|
buttonText: 'View certificate',
|
|
model: 'pki/certificate/base',
|
|
route: 'vault.cluster.secrets.backend.pki.certificates.certificate.details',
|
|
queryObject: { backend: this.selectedEngine.id },
|
|
};
|
|
case 'View issuer':
|
|
return {
|
|
title: 'Issuer',
|
|
placeholder: 'Type issuer name or ID',
|
|
buttonText: 'View issuer',
|
|
model: 'pki/issuer',
|
|
route: 'vault.cluster.secrets.backend.pki.issuers.issuer.details',
|
|
nameKey: 'issuerName',
|
|
queryObject: { backend: this.selectedEngine.id },
|
|
objectKeys: ['id', 'issuerName'],
|
|
};
|
|
default:
|
|
return {
|
|
placeholder: 'Please select an action above',
|
|
buttonText: 'Select an action',
|
|
model: '',
|
|
};
|
|
}
|
|
}
|
|
|
|
get filteredSecretEngines() {
|
|
return this.args.secretsEngines?.filter(
|
|
(engine) => (engine.type === 'kv' && engine.version == 2) || QUICK_ACTION_ENGINES.includes(engine.type)
|
|
);
|
|
}
|
|
|
|
get mountOptions() {
|
|
return this.filteredSecretEngines?.map((engine) => {
|
|
const { id, type } = engine;
|
|
|
|
return { name: id, type, id };
|
|
});
|
|
}
|
|
|
|
@action
|
|
handleSearchEngineSelect([selection]) {
|
|
this.selectedEngine = selection;
|
|
// reset tracked properties
|
|
this.selectedAction = null;
|
|
this.paramValue = null;
|
|
}
|
|
|
|
@action
|
|
setSelectedAction(selectedAction) {
|
|
this.selectedAction = selectedAction;
|
|
this.paramValue = null;
|
|
}
|
|
|
|
@action
|
|
handleActionSelect(val) {
|
|
if (Array.isArray(val)) {
|
|
this.paramValue = val[0];
|
|
} else {
|
|
this.paramValue = val;
|
|
}
|
|
}
|
|
|
|
@action
|
|
navigateToPage() {
|
|
let route = this.searchSelectParams.route;
|
|
// If search-select falls back to stringInput, paramValue is a string not object
|
|
let param = this.paramValue.id || this.paramValue;
|
|
|
|
// kv has a special use case where if the paramValue ends in a '/' you should
|
|
// link to different route
|
|
if (this.selectedEngine.type === 'kv') {
|
|
const path = this.paramValue.path || this.paramValue;
|
|
route = pathIsDirectory(path)
|
|
? 'vault.cluster.secrets.backend.kv.list-directory'
|
|
: 'vault.cluster.secrets.backend.kv.secret.index';
|
|
param = path;
|
|
}
|
|
|
|
this.router.transitionTo(route, this.selectedEngine.id, param);
|
|
}
|
|
}
|