mirror of
https://github.com/hashicorp/vault.git
synced 2026-01-08 10:11:29 +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>
135 lines
3.0 KiB
JavaScript
135 lines
3.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Model, { attr } from '@ember-data/model';
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
|
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
|
|
|
|
export const KEY_TYPES = [
|
|
'aes256-gcm96',
|
|
'rsa-2048',
|
|
'rsa-3072',
|
|
'rsa-4096',
|
|
'ecdsa-p256',
|
|
'ecdsa-p384',
|
|
'ecdsa-p521',
|
|
];
|
|
export default class KeymgmtKeyModel extends Model {
|
|
@attr('string', {
|
|
label: 'Key name',
|
|
subText: 'This is the name of the key that shows in Vault.',
|
|
})
|
|
name;
|
|
|
|
@attr('string')
|
|
backend;
|
|
|
|
@attr('string', {
|
|
subText: 'The type of cryptographic key that will be created.',
|
|
possibleValues: KEY_TYPES,
|
|
defaultValue: 'rsa-2048',
|
|
})
|
|
type;
|
|
|
|
@attr('boolean', {
|
|
label: 'Allow deletion',
|
|
defaultValue: false,
|
|
})
|
|
deletionAllowed;
|
|
|
|
@attr('number', {
|
|
label: 'Current version',
|
|
})
|
|
latestVersion;
|
|
|
|
@attr('number', {
|
|
defaultValue: 0,
|
|
defaultShown: 'All versions enabled',
|
|
})
|
|
minEnabledVersion;
|
|
|
|
@attr('array')
|
|
versions;
|
|
|
|
// The following are calculated in serializer
|
|
@attr('date')
|
|
created;
|
|
|
|
@attr('date', {
|
|
defaultShown: 'Not yet rotated',
|
|
})
|
|
lastRotated;
|
|
|
|
// The following are from endpoints other than the main read one
|
|
@attr() provider; // string, or object with permissions error
|
|
@attr() distribution;
|
|
|
|
icon = 'key';
|
|
|
|
get hasVersions() {
|
|
return this.versions.length > 1;
|
|
}
|
|
|
|
get createFields() {
|
|
const createFields = ['name', 'type', 'deletionAllowed'];
|
|
return expandAttributeMeta(this, createFields);
|
|
}
|
|
|
|
get updateFields() {
|
|
return expandAttributeMeta(this, ['minEnabledVersion', 'deletionAllowed']);
|
|
}
|
|
get showFields() {
|
|
return expandAttributeMeta(this, [
|
|
'name',
|
|
'created',
|
|
'type',
|
|
'deletionAllowed',
|
|
'latestVersion',
|
|
'minEnabledVersion',
|
|
'lastRotated',
|
|
]);
|
|
}
|
|
|
|
get keyTypeOptions() {
|
|
return expandAttributeMeta(this, ['type'])[0];
|
|
}
|
|
|
|
get distFields() {
|
|
return [
|
|
{
|
|
name: 'name',
|
|
type: 'string',
|
|
label: 'Distributed name',
|
|
subText: 'The name given to the key by the provider.',
|
|
},
|
|
{ name: 'purpose', type: 'string', label: 'Key Purpose' },
|
|
{ name: 'protection', type: 'string', subText: 'Where cryptographic operations are performed.' },
|
|
];
|
|
}
|
|
|
|
@lazyCapabilities(apiPath`${'backend'}/key/${'id'}`, 'backend', 'id') keyPath;
|
|
@lazyCapabilities(apiPath`${'backend'}/key`, 'backend') keysPath;
|
|
@lazyCapabilities(apiPath`${'backend'}/key/${'id'}/kms`, 'backend', 'id') keyProvidersPath;
|
|
|
|
get canCreate() {
|
|
return this.keyPath.get('canCreate');
|
|
}
|
|
get canDelete() {
|
|
return this.keyPath.get('canDelete');
|
|
}
|
|
get canEdit() {
|
|
return this.keyPath.get('canUpdate');
|
|
}
|
|
get canRead() {
|
|
return this.keyPath.get('canRead');
|
|
}
|
|
get canList() {
|
|
return this.keysPath.get('canList');
|
|
}
|
|
get canListProviders() {
|
|
return this.keyProvidersPath.get('canList');
|
|
}
|
|
}
|