mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02: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>
89 lines
2.5 KiB
JavaScript
89 lines
2.5 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Model, { attr } from '@ember-data/model';
|
|
import { computed } from '@ember/object';
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
|
const CREDENTIAL_TYPES = [
|
|
{
|
|
value: 'iam_user',
|
|
displayName: 'IAM User',
|
|
},
|
|
{
|
|
value: 'assumed_role',
|
|
displayName: 'Assumed Role',
|
|
},
|
|
{
|
|
value: 'federation_token',
|
|
displayName: 'Federation Token',
|
|
},
|
|
];
|
|
|
|
const DISPLAY_FIELDS = ['accessKey', 'secretKey', 'securityToken', 'leaseId', 'renewable', 'leaseDuration'];
|
|
export default Model.extend({
|
|
helpText:
|
|
'For Vault roles of credential type iam_user, there are no inputs, just submit the form. Choose a type to change the input options.',
|
|
role: attr('object', {
|
|
readOnly: true,
|
|
}),
|
|
|
|
credentialType: attr('string', {
|
|
defaultValue: 'iam_user',
|
|
possibleValues: CREDENTIAL_TYPES,
|
|
readOnly: true,
|
|
}),
|
|
|
|
roleArn: attr('string', {
|
|
label: 'Role ARN',
|
|
helpText:
|
|
'The ARN of the role to assume if credential_type on the Vault role is assumed_role. Optional if the role has a single role ARN; required otherwise.',
|
|
}),
|
|
|
|
ttl: attr({
|
|
editType: 'ttl',
|
|
defaultValue: '3600s',
|
|
setDefault: true,
|
|
label: 'TTL',
|
|
helpText:
|
|
'Specifies the TTL for the use of the STS token. Valid only when credential_type is assumed_role or federation_token.',
|
|
}),
|
|
leaseId: attr('string'),
|
|
renewable: attr('boolean'),
|
|
leaseDuration: attr('number'),
|
|
accessKey: attr('string'),
|
|
secretKey: attr('string'),
|
|
securityToken: attr('string'),
|
|
|
|
attrs: computed('credentialType', 'accessKey', 'securityToken', function () {
|
|
const type = this.credentialType;
|
|
const fieldsForType = {
|
|
iam_user: ['credentialType'],
|
|
assumed_role: ['credentialType', 'ttl', 'roleArn'],
|
|
federation_token: ['credentialType', 'ttl'],
|
|
};
|
|
if (this.accessKey || this.securityToken) {
|
|
return expandAttributeMeta(this, DISPLAY_FIELDS.slice(0));
|
|
}
|
|
return expandAttributeMeta(this, fieldsForType[type].slice(0));
|
|
}),
|
|
|
|
toCreds: computed('accessKey', 'secretKey', 'securityToken', 'leaseId', function () {
|
|
const props = {
|
|
accessKey: this.accessKey,
|
|
secretKey: this.secretKey,
|
|
securityToken: this.securityToken,
|
|
leaseId: this.leaseId,
|
|
};
|
|
const propsWithVals = Object.keys(props).reduce((ret, prop) => {
|
|
if (props[prop]) {
|
|
ret[prop] = props[prop];
|
|
return ret;
|
|
}
|
|
return ret;
|
|
}, {});
|
|
return JSON.stringify(propsWithVals, null, 2);
|
|
}),
|
|
});
|