refactor: 💡 Update passphrase to private_key_passphrase (#1290)
✅ Closes: ICU-5916
This commit is contained in:
1 parent
cb3104a624
commit
83c7b76f48
7 files changed
+30
-30
No files matched your search
@@ -73,7 +73,7 @@ export default class GeneratedCredentialModel extends BaseModel {
|
||||
@attr('string', {
|
||||
for: 'ssh_private_key',
|
||||
isNestedAttribute: true,
|
||||
description: 'The passphrase for credential.',
|
||||
description: 'The private key passphrase for credential.',
|
||||
})
|
||||
passphrase;
|
||||
private_key_passphrase;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export default class CredentialSerializer extends ApplicationSerializer {
|
||||
const serialized = super.serialize(...arguments);
|
||||
// Remove non-username_password type attributes
|
||||
delete serialized.attributes.private_key;
|
||||
delete serialized.attributes.passphrase;
|
||||
delete serialized.attributes.private_key_passphrase;
|
||||
// Remove password from the payload if null
|
||||
// or empty string. This allows the user to only update
|
||||
// the username without providing the password again.
|
||||
@@ -42,13 +42,13 @@ export default class CredentialSerializer extends ApplicationSerializer {
|
||||
const serialized = super.serialize(...arguments);
|
||||
// Remove non-ssh_private_key type attributes
|
||||
delete serialized.attributes.password;
|
||||
// Remove private_key and/or passphrase from the payload if null
|
||||
// or empty string. This allows the user to only update
|
||||
// Remove private_key and/or private_key_passphrase from the payload
|
||||
// if null or empty string. This allows the user to only update
|
||||
// the username without providing the private key and passphrase again.
|
||||
// Users cannot unset the private key or passphrase, they would have
|
||||
// to delete the credential entirely.
|
||||
if (!serialized?.attributes?.passphrase)
|
||||
delete serialized.attributes.passphrase;
|
||||
if (!serialized?.attributes?.private_key_passphrase)
|
||||
delete serialized.attributes.private_key_passphrase;
|
||||
if (!serialized?.attributes?.private_key)
|
||||
delete serialized.attributes.private_key;
|
||||
return serialized;
|
||||
@@ -57,10 +57,10 @@ export default class CredentialSerializer extends ApplicationSerializer {
|
||||
normalize(typeClass, hash, ...rest) {
|
||||
const normalizedHash = copy(hash, true);
|
||||
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
|
||||
// Remove passphrase as we don't track it after being created/updated
|
||||
normalized.data.attributes.passphrase = '';
|
||||
// Remove secret fields as we don't track them after being created/updated
|
||||
normalized.data.attributes.password = '';
|
||||
normalized.data.attributes.private_key = '';
|
||||
normalized.data.attributes.private_key_passphrase = '';
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,11 @@ export default ApplicationSerializer.extend({
|
||||
);
|
||||
json.credential_store_id = model.credentialStoreId;
|
||||
|
||||
// in a real API, the password, private_key, and passphrase
|
||||
// field is not returned so we delete it from the response
|
||||
// in a real API, the password, private_key, and private_key_passphrase
|
||||
// fields are not returned so we delete them from the response
|
||||
delete json.attributes?.password;
|
||||
delete json.attributes?.private_key;
|
||||
delete json.attributes?.passphrase;
|
||||
delete json.attributes?.private_key_passphrase;
|
||||
|
||||
return json;
|
||||
},
|
||||
|
||||
@@ -66,7 +66,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('credential');
|
||||
const record = store.createRecord('credential', {
|
||||
passphrase: 'passphrasesaresosecure',
|
||||
private_key_passphrase: 'passphrasesaresosecure',
|
||||
private_key: 'superPriveKey',
|
||||
username: 'user',
|
||||
credential_store_id: 'csst_i7p1eu0Nw8',
|
||||
@@ -80,7 +80,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
|
||||
assert.deepEqual(serializedRecord, {
|
||||
attributes: {
|
||||
passphrase: 'passphrasesaresosecure',
|
||||
private_key_passphrase: 'passphrasesaresosecure',
|
||||
private_key: 'superPriveKey',
|
||||
username: 'user',
|
||||
},
|
||||
@@ -97,7 +97,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('credential');
|
||||
const record = store.createRecord('credential', {
|
||||
passphrase: '',
|
||||
private_key_passphrase: '',
|
||||
private_key: '',
|
||||
username: 'user',
|
||||
credential_store_id: 'csst_i7p1eu0Nw8',
|
||||
@@ -143,7 +143,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
type: 'username_password',
|
||||
username: 'username',
|
||||
version: 1,
|
||||
passphrase: '',
|
||||
private_key_passphrase: '',
|
||||
private_key: '',
|
||||
password: '',
|
||||
},
|
||||
@@ -165,7 +165,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
type: 'ssh_private_key',
|
||||
attributes: {
|
||||
username: 'username',
|
||||
passphrase: 'random',
|
||||
private_key_passphrase: 'random',
|
||||
private_key_hmac: 'completenonsense',
|
||||
},
|
||||
};
|
||||
@@ -177,7 +177,7 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
type: 'ssh_private_key',
|
||||
username: 'username',
|
||||
version: 1,
|
||||
passphrase: '',
|
||||
private_key_passphrase: '',
|
||||
private_key: '',
|
||||
password: '',
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user