diff --git a/addons/api/addon/generated/models/credential-library.js b/addons/api/addon/generated/models/credential-library.js index 9838bc80a..3d8ba617e 100644 --- a/addons/api/addon/generated/models/credential-library.js +++ b/addons/api/addon/generated/models/credential-library.js @@ -76,13 +76,13 @@ export default class GeneratedCredentialLibraryModel extends BaseModel { path; @attr('string', { - for: ['vault-generic', 'vault-ldap'], + for: 'vault-generic', description: 'It indicates the type of credential the library returns.', }) credential_type; @attr('object-as-array', { - for: ['vault-generic', 'vault-ldap'], + for: 'vault-generic', description: 'It indicates the credential mapping overrides.', }) credential_mapping_overrides; diff --git a/addons/api/addon/serializers/credential-library.js b/addons/api/addon/serializers/credential-library.js index bc96b26a6..5e2186eb7 100644 --- a/addons/api/addon/serializers/credential-library.js +++ b/addons/api/addon/serializers/credential-library.js @@ -7,7 +7,6 @@ import ApplicationSerializer from './application'; import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC, TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, - TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, options, } from '../models/credential-library'; @@ -30,8 +29,6 @@ export default class CredentialLibrarySerializer extends ApplicationSerializer { return this.serializeVaultGeneric(...arguments); case TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE: return this.serializeVaultSshCertificate(...arguments); - case TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP: - return this.serializeVaultLdap(...arguments); default: return super.serialize(...arguments); } @@ -64,15 +61,6 @@ export default class CredentialLibrarySerializer extends ApplicationSerializer { } } - serializeVaultLdap(snapshot) { - const { isNew } = snapshot; - const serialized = super.serialize(...arguments); - if (serialized.attributes) { - this.handleCredentialMappingOverrides(serialized, isNew); - return serialized; - } - } - /** * Handle credential mapping overrides for serialization. * @param {Object} serialized - The serialized object. diff --git a/addons/api/mirage/factories/credential-library.js b/addons/api/mirage/factories/credential-library.js index 05f7ef878..b7a783433 100644 --- a/addons/api/mirage/factories/credential-library.js +++ b/addons/api/mirage/factories/credential-library.js @@ -23,9 +23,6 @@ export default factory.extend({ if (this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC) { return options.credential_types[i % options.credential_types.length]; } - if (this.type === TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP) { - return options.credential_types[2]; // Only supports username, password & domain credential type - } }, authorized_actions: () => permissions.authorizedActionsFor('credential-library') || [ diff --git a/addons/api/tests/unit/serializers/credential-library-test.js b/addons/api/tests/unit/serializers/credential-library-test.js index da7106a02..817ecb42c 100644 --- a/addons/api/tests/unit/serializers/credential-library-test.js +++ b/addons/api/tests/unit/serializers/credential-library-test.js @@ -291,11 +291,6 @@ module('Unit | Serializer | credential library', function (hooks) { description: 'Description', path: '/vault/path', version: 1, - credential_type: 'username_password_domain', - credential_mapping_overrides: [ - { key: 'username_attribute', value: 'user' }, - { key: 'domain_attribute', value: 'domain' }, - ], }); const snapshot = record._createSnapshot(); const serializedRecord = serializer.serialize(snapshot); @@ -306,11 +301,6 @@ module('Unit | Serializer | credential library', function (hooks) { name: 'Name', description: 'Description', version: 1, - credential_type: 'username_password_domain', - credential_mapping_overrides: { - username_attribute: 'user', - domain_attribute: 'domain', - }, attributes: { path: '/vault/path', }, @@ -326,15 +316,10 @@ module('Unit | Serializer | credential library', function (hooks) { type: 'credential-library', attributes: { type: TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, - name: 'Name', + name: 'Test', description: 'Description', path: '/vault/path', version: 1, - credential_type: 'username_password_domain', - credential_mapping_overrides: [ - { key: 'username_attribute', value: 'user' }, - { key: 'domain_attribute', value: 'domain' }, - ], }, }, }); @@ -345,15 +330,9 @@ module('Unit | Serializer | credential library', function (hooks) { assert.deepEqual(serializedRecord, { type: TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, credential_store_id: null, - name: 'Name', + name: 'Test', description: 'Description', version: 1, - credential_type: 'username_password_domain', - credential_mapping_overrides: { - username_attribute: 'user', - domain_attribute: 'domain', - password_attribute: null, - }, attributes: { path: '/vault/path', }, diff --git a/ui/admin/app/components/form/credential-library/vault-ldap/index.hbs b/ui/admin/app/components/form/credential-library/vault-ldap/index.hbs index 56b8e9f10..cf7106de1 100644 --- a/ui/admin/app/components/form/credential-library/vault-ldap/index.hbs +++ b/ui/admin/app/components/form/credential-library/vault-ldap/index.hbs @@ -96,25 +96,6 @@ {{/if}} - - {{t - 'resources.credential-library.form.credential_type.label' - }} - - {{t 'resources.credential-library.form.credential_type.description'}} - - - - - {{#if (can 'save model' @model)}} - cred.credential_type !== TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, + (cred) => { + return ( + cred.credential_type !== TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN && + cred.type !== TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP + ); + }, ); // credentials for RDP @@ -143,7 +147,8 @@ module( [ TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, TYPE_CREDENTIAL_USERNAME_PASSWORD, - ].includes(cred.credential_type), + ].includes(cred.credential_type) || + cred.type === TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, ); filteredCredentialsForRDP = selectItems( this.server.schema.credentials, @@ -188,9 +193,13 @@ module( // SSH specific credential sources getCredentialLibraryCount = () => - this.server.schema.credentialLibraries.where( - (c) => c.credential_type !== TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, - ).models.length; + this.server.schema.credentialLibraries.where((c) => { + return ( + c.credential_type !== TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN && + c.type !== TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP + ); + }).models.length; + getCredentialCount = () => this.server.schema.credentials.where( (cred) => @@ -209,11 +218,13 @@ module( ].includes(cred.type), ).models.length; getCredentialLibraryForRDPCount = () => - this.server.schema.credentialLibraries.where((cred) => - [ - TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, - TYPE_CREDENTIAL_USERNAME_PASSWORD, - ].includes(cred.credential_type), + this.server.schema.credentialLibraries.where( + (cred) => + [ + TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, + TYPE_CREDENTIAL_USERNAME_PASSWORD, + ].includes(cred.credential_type) || + cred.type === TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, ).models.length; credentialSourceCount =