331b6ce6f5
Update UI for AWS secret backend refactor * Support empty AWS policy documents * Try to make ARN input multiple * move aws-role serializer to use the application serializer as the base * support editing strings as JSON in the form field component * update model, form and show to use form-component component, and swap fields based on credential type * fix tests * unify credential generation for aws and remove the STS specific action in the UI * add label to the new json string form field
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
import DS from 'ember-data';
|
|
import Ember from 'ember';
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
|
const { attr } = DS;
|
|
const { computed } = Ember;
|
|
const CREATE_FIELDS = ['ttl', 'roleArn'];
|
|
|
|
const DISPLAY_FIELDS = ['accessKey', 'secretKey', 'securityToken', 'leaseId', 'renewable', 'leaseDuration'];
|
|
export default DS.Model.extend({
|
|
helpText:
|
|
'For Vault roles that have a credential type of iam_user, these attributes are optional and you may simply submit the form.',
|
|
role: attr('object', {
|
|
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',
|
|
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('accessKey', 'securityToken', function() {
|
|
let keys =
|
|
this.get('accessKey') || this.get('securityToken') ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0);
|
|
return expandAttributeMeta(this, keys);
|
|
}),
|
|
|
|
toCreds: computed('accessKey', 'secretKey', 'securityToken', 'leaseId', function() {
|
|
const props = this.getProperties('accessKey', 'secretKey', 'securityToken', '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);
|
|
}),
|
|
});
|