mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-12 22:31:39 +01:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
import { withConfig } from 'pki/decorators/check-issuers';
|
|
import { hash } from 'rsvp';
|
|
|
|
export const PKI_DEFAULT_EMPTY_STATE_MSG =
|
|
"This PKI mount hasn't yet been configured with a certificate issuer.";
|
|
|
|
export const getCliMessage = (msg) => {
|
|
if (!msg) return PKI_DEFAULT_EMPTY_STATE_MSG;
|
|
|
|
return `${PKI_DEFAULT_EMPTY_STATE_MSG} There are existing ${msg}. Use the CLI to perform any operations with them until an issuer is configured.`;
|
|
};
|
|
|
|
@withConfig()
|
|
export default class PkiOverviewRoute extends Route {
|
|
@service secretMountPath;
|
|
@service auth;
|
|
@service store;
|
|
|
|
async fetchAllCertificates() {
|
|
try {
|
|
return await this.store.query('pki/certificate/base', { backend: this.secretMountPath.currentPath });
|
|
} catch (e) {
|
|
return e.httpStatus;
|
|
}
|
|
}
|
|
|
|
async fetchAllRoles() {
|
|
try {
|
|
return await this.store.query('pki/role', { backend: this.secretMountPath.currentPath });
|
|
} catch (e) {
|
|
return e.httpStatus;
|
|
}
|
|
}
|
|
|
|
async fetchAllIssuers() {
|
|
try {
|
|
return await this.store.query('pki/issuer', { backend: this.secretMountPath.currentPath });
|
|
} catch (e) {
|
|
return e.httpStatus;
|
|
}
|
|
}
|
|
|
|
async model() {
|
|
return hash({
|
|
hasConfig: this.shouldPromptConfig,
|
|
engine: this.modelFor('application'),
|
|
roles: this.fetchAllRoles(),
|
|
issuers: this.fetchAllIssuers(),
|
|
certificates: this.fetchAllCertificates(),
|
|
});
|
|
}
|
|
|
|
setupController(controller, resolvedModel) {
|
|
super.setupController(controller, resolvedModel);
|
|
const roles = resolvedModel.roles;
|
|
const certificates = resolvedModel.certificates;
|
|
|
|
controller.notConfiguredMessage = getCliMessage();
|
|
|
|
if (roles?.length) controller.notConfiguredMessage = getCliMessage('roles');
|
|
if (certificates?.length) controller.notConfiguredMessage = getCliMessage('certificates');
|
|
if (roles?.length && certificates?.length)
|
|
controller.notConfiguredMessage = getCliMessage('roles and certificates');
|
|
}
|
|
}
|