2018-09-25 16:28:26 +00:00
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import { computed } from '@ember/object';
|
2018-04-03 14:16:57 +00:00
|
|
|
import DS from 'ember-data';
|
2018-06-12 21:06:37 +00:00
|
|
|
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
|
|
|
|
import fieldToAttrs from 'vault/utils/field-to-attrs';
|
2019-02-14 18:52:34 +00:00
|
|
|
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs';
|
2018-04-03 14:16:57 +00:00
|
|
|
const { attr } = DS;
|
|
|
|
|
|
|
|
export default DS.Model.extend({
|
|
|
|
backend: attr('string', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
name: attr('string', {
|
|
|
|
label: 'Role name',
|
|
|
|
fieldValue: 'id',
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
2019-02-14 18:52:34 +00:00
|
|
|
useOpenAPI: true,
|
|
|
|
getHelpUrl: function(backend) {
|
|
|
|
return `/v1/${backend}/roles/example?help=1`;
|
|
|
|
},
|
2018-06-12 21:06:37 +00:00
|
|
|
updatePath: lazyCapabilities(apiPath`${'backend'}/roles/${'id'}`, 'backend', 'id'),
|
2018-09-25 16:28:26 +00:00
|
|
|
canDelete: alias('updatePath.canDelete'),
|
|
|
|
canEdit: alias('updatePath.canUpdate'),
|
|
|
|
canRead: alias('updatePath.canRead'),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
generatePath: lazyCapabilities(apiPath`${'backend'}/issue/${'id'}`, 'backend', 'id'),
|
2018-09-25 16:28:26 +00:00
|
|
|
canGenerate: alias('generatePath.canUpdate'),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
signPath: lazyCapabilities(apiPath`${'backend'}/sign/${'id'}`, 'backend', 'id'),
|
2018-09-25 16:28:26 +00:00
|
|
|
canSign: alias('signPath.canUpdate'),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
signVerbatimPath: lazyCapabilities(apiPath`${'backend'}/sign-verbatim/${'id'}`, 'backend', 'id'),
|
2018-09-25 16:28:26 +00:00
|
|
|
canSignVerbatim: alias('signVerbatimPath.canUpdate'),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
fieldGroups: computed(function() {
|
2019-02-14 18:52:34 +00:00
|
|
|
let groups = [
|
2018-04-03 14:16:57 +00:00
|
|
|
{ default: ['name', 'keyType'] },
|
|
|
|
{
|
|
|
|
Options: [
|
|
|
|
'keyBits',
|
|
|
|
'ttl',
|
|
|
|
'maxTtl',
|
|
|
|
'allowAnyName',
|
|
|
|
'enforceHostnames',
|
|
|
|
'allowIpSans',
|
2018-04-09 02:09:29 +00:00
|
|
|
'requireCn',
|
2018-04-03 14:16:57 +00:00
|
|
|
'useCsrCommonName',
|
|
|
|
'useCsrSans',
|
|
|
|
'ou',
|
|
|
|
'organization',
|
|
|
|
'keyUsage',
|
|
|
|
'allowedOtherSans',
|
2018-10-02 15:10:43 +00:00
|
|
|
'notBeforeDuration',
|
2018-04-03 14:16:57 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'Address Options': ['country', 'locality', 'province', 'streetAddress', 'postalCode'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'Domain Handling': [
|
|
|
|
'allowLocalhost',
|
|
|
|
'allowBareDomains',
|
|
|
|
'allowSubdomains',
|
|
|
|
'allowGlobDomains',
|
|
|
|
'allowedDomains',
|
|
|
|
],
|
|
|
|
},
|
2018-06-12 21:06:37 +00:00
|
|
|
{
|
|
|
|
'Extended Key Usage': [
|
|
|
|
'serverFlag',
|
|
|
|
'clientFlag',
|
|
|
|
'codeSigningFlag',
|
|
|
|
'emailProtectionFlag',
|
|
|
|
'extKeyUsageOids',
|
|
|
|
],
|
|
|
|
},
|
2018-04-09 02:09:29 +00:00
|
|
|
{
|
2019-02-14 18:52:34 +00:00
|
|
|
Advanced: ['generateLease', 'noStore', 'basicConstraintsValidForNonCa', 'policyIdentifiers'],
|
2018-04-09 02:09:29 +00:00
|
|
|
},
|
2018-04-03 14:16:57 +00:00
|
|
|
];
|
2019-02-14 18:52:34 +00:00
|
|
|
let excludedFields = ['extKeyUsage'];
|
|
|
|
if (this.newFields) {
|
|
|
|
groups = combineFieldGroups(groups, this.newFields, excludedFields);
|
|
|
|
}
|
2018-06-12 21:06:37 +00:00
|
|
|
return fieldToAttrs(this, groups);
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
|
|
|
});
|