open-vault/ui/app/models/role-pki.js

89 lines
2.5 KiB
JavaScript
Raw Normal View History

import { alias } from '@ember/object/computed';
import { computed } from '@ember/object';
2018-04-03 14:16:57 +00:00
import DS from 'ember-data';
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`;
},
updatePath: lazyCapabilities(apiPath`${'backend'}/roles/${'id'}`, 'backend', 'id'),
canDelete: alias('updatePath.canDelete'),
canEdit: alias('updatePath.canUpdate'),
canRead: alias('updatePath.canRead'),
2018-04-03 14:16:57 +00:00
generatePath: lazyCapabilities(apiPath`${'backend'}/issue/${'id'}`, 'backend', 'id'),
canGenerate: alias('generatePath.canUpdate'),
2018-04-03 14:16:57 +00:00
signPath: lazyCapabilities(apiPath`${'backend'}/sign/${'id'}`, 'backend', 'id'),
canSign: alias('signPath.canUpdate'),
2018-04-03 14:16:57 +00:00
signVerbatimPath: lazyCapabilities(apiPath`${'backend'}/sign-verbatim/${'id'}`, 'backend', 'id'),
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',
'requireCn',
2018-04-03 14:16:57 +00:00
'useCsrCommonName',
'useCsrSans',
'ou',
'organization',
'keyUsage',
'allowedOtherSans',
'notBeforeDuration',
2018-04-03 14:16:57 +00:00
],
},
{
'Address Options': ['country', 'locality', 'province', 'streetAddress', 'postalCode'],
},
{
'Domain Handling': [
'allowLocalhost',
'allowBareDomains',
'allowSubdomains',
'allowGlobDomains',
'allowedDomains',
],
},
{
'Extended Key Usage': [
'serverFlag',
'clientFlag',
'codeSigningFlag',
'emailProtectionFlag',
'extKeyUsageOids',
],
},
{
2019-02-14 18:52:34 +00:00
Advanced: ['generateLease', 'noStore', 'basicConstraintsValidForNonCa', 'policyIdentifiers'],
},
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);
}
return fieldToAttrs(this, groups);
2018-04-03 14:16:57 +00:00
}),
});