Vault SSH Cert Feature (#1596)
* feat: 🎸 Update models for vault ssh cert feature (#1591) ✅ Closes: ICU-7546 * feat: 🎸 Setup types in cred library forms and use HDS component (#1597) * feat: 🎸 Setup types in cred library forms and use HDS component ✅ Closes: ICU-7673 * feat: 🎸 Add vault ssh cert type for credential library (#1608) * feat: 🎸 Add vault ssh cert type for credential library ✅ Closes: ICU-7678 * feat: 🎸 Enable feature flag for vault ssh cert work (#1614) * fix: 🐛 Change fields to optional as they get default by backend (#1615) * Chore/cleanup vault ssh cert (#1616)
This commit is contained in:
1 parent
e3772352ea
commit
f0530e1f8f
34 files changed
+1421
-182
No files matched your search
@@ -2,11 +2,11 @@ import ModelAbility from './model';
|
||||
/**
|
||||
* Provides abilities for credential.
|
||||
*/
|
||||
export default class CredentialLibaryAbility extends ModelAbility {
|
||||
export default class CredentialLibraryAbility extends ModelAbility {
|
||||
// =permissions
|
||||
|
||||
/**
|
||||
* Only "known" credential libary types may be read.
|
||||
* Only "known" credential library types may be read.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canRead() {
|
||||
|
||||
@@ -67,4 +67,50 @@ export default class GeneratedCredentialLibraryModel extends BaseModel {
|
||||
description: 'The path in Vault to request credentials from.',
|
||||
})
|
||||
path;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The username to use when making an SSH connection.',
|
||||
})
|
||||
username;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The desired key type to use when generating a private key.',
|
||||
})
|
||||
key_type;
|
||||
|
||||
@attr('number', {
|
||||
isNestedAttribute: true,
|
||||
description:
|
||||
'Specifies the number of bits used when generating the private key. Not used if key type is ed25519',
|
||||
})
|
||||
key_bits;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'Specifies the requested time to live for the certificate.',
|
||||
})
|
||||
ttl;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description:
|
||||
'Specifies the key id that the created certificate should have.',
|
||||
})
|
||||
key_id;
|
||||
|
||||
@attr('object-as-array', {
|
||||
isNestedAttribute: true,
|
||||
description:
|
||||
'Specifies a map of the critical options that the certificate should be signed for.',
|
||||
})
|
||||
critical_options;
|
||||
|
||||
@attr('object-as-array', {
|
||||
isNestedAttribute: true,
|
||||
description:
|
||||
'Specifies a map of the extensions that the certificate should be signed for.',
|
||||
})
|
||||
extensions;
|
||||
}
|
||||
@@ -5,12 +5,20 @@ import GeneratedCredentialLibraryModel from '../generated/models/credential-libr
|
||||
*/
|
||||
export const options = {
|
||||
http_method: ['GET', 'POST'],
|
||||
key_type: ['ed25519', 'ecdsa', 'rsa'],
|
||||
};
|
||||
|
||||
export const TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC = 'vault-generic';
|
||||
export const TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE =
|
||||
'vault-ssh-certificate';
|
||||
|
||||
/**
|
||||
* Supported Credential Library types.
|
||||
*/
|
||||
export const types = ['vault'];
|
||||
export const TYPES_CREDENTIAL_LIBRARY = Object.freeze([
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
]);
|
||||
|
||||
export default class CredentialLibraryModel extends GeneratedCredentialLibraryModel {
|
||||
// =attributes
|
||||
@@ -20,7 +28,7 @@ export default class CredentialLibraryModel extends GeneratedCredentialLibraryMo
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isUnknown() {
|
||||
return !types.includes(this.type);
|
||||
return !TYPES_CREDENTIAL_LIBRARY.includes(this.type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +36,25 @@ export default class CredentialLibraryModel extends GeneratedCredentialLibraryMo
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isVault() {
|
||||
return this.type === 'vault';
|
||||
return (
|
||||
this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC ||
|
||||
this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* True if credential is a generic vault type.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isVaultGeneric() {
|
||||
return this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if credential is a vault ssh cert type.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isVaultSSHCertificate() {
|
||||
return this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from '../models/credential-library';
|
||||
|
||||
export default class CredentialLibrarySerializer extends ApplicationSerializer {
|
||||
// =properties
|
||||
@@ -16,6 +17,10 @@ export default class CredentialLibrarySerializer extends ApplicationSerializer {
|
||||
serialize() {
|
||||
const serialized = super.serialize(...arguments);
|
||||
if (serialized.attributes) {
|
||||
if (serialized.type !== TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC) {
|
||||
delete serialized.attributes.http_method;
|
||||
}
|
||||
|
||||
// Serialize `http_request_body` only if `http_method` is POST
|
||||
if (!serialized.attributes?.http_method?.match(/post/i))
|
||||
delete serialized.attributes.http_request_body;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class ObjectAsArrayTransform extends Transform {
|
||||
deserialize(serialized) {
|
||||
const obj = serialized || {};
|
||||
return Object.entries(obj).map(([key, value]) => ({ key, value }));
|
||||
}
|
||||
serialize(deserialized) {
|
||||
const array = deserialized || [];
|
||||
|
||||
if (!array.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array.reduce((result, currentValue) => {
|
||||
const { key, value } = currentValue;
|
||||
result[key] = value;
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user