36ccfaa3aa
* adds development workflow to mirage config * adds mirage handler and factory for mfa workflow * adds mfa handling to auth service and cluster adapter * moves auth success logic from form to controller * adds mfa form component * shows delayed auth message for all methods * adds new code delay to mfa form * adds error views * fixes merge conflict * adds integration tests for mfa-form component * fixes auth tests * updates mfa response handling to align with backend * updates mfa-form to handle multiple methods and constraints * adds noDefault arg to Select component * updates mirage mfa handler to align with backend and adds generator for various mfa scenarios * adds tests * flaky test fix attempt * reverts test fix attempt * adds changelog entry * updates comments for todo items * removes faker from mfa mirage factory and handler * adds number to word helper * fixes tests * Revert "Merge branch 'main' into ui/mfa" This reverts commit 8ee6a6aaa1b6c9ec16b985c10d91c3806819ec40, reversing changes made to 2428dd6cca07bb41cda3f453619646ca3a88bfd0. * format-ttl helper fix from main
66 lines
2.2 KiB
JavaScript
66 lines
2.2 KiB
JavaScript
import RESTSerializer from '@ember-data/serializer/rest';
|
|
import { assign } from '@ember/polyfills';
|
|
import { decamelize } from '@ember/string';
|
|
|
|
export default RESTSerializer.extend({
|
|
primaryKey: 'name',
|
|
|
|
keyForAttribute: function (attr) {
|
|
return decamelize(attr);
|
|
},
|
|
|
|
normalizeSecrets(payload) {
|
|
if (payload.data.keys && Array.isArray(payload.data.keys)) {
|
|
const secrets = payload.data.keys.map((secret) => ({ name: secret, backend: payload.backend }));
|
|
return secrets;
|
|
}
|
|
assign(payload, payload.data);
|
|
delete payload.data;
|
|
// timestamps for these two are in seconds...
|
|
if (
|
|
payload.type === 'aes256-gcm96' ||
|
|
payload.type === 'chacha20-poly1305' ||
|
|
payload.type === 'aes128-gcm96'
|
|
) {
|
|
for (let version in payload.keys) {
|
|
payload.keys[version] = payload.keys[version] * 1000;
|
|
}
|
|
}
|
|
payload.id = payload.name;
|
|
return [payload];
|
|
},
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
const nullResponses = ['updateRecord', 'createRecord', 'deleteRecord'];
|
|
const secrets = nullResponses.includes(requestType)
|
|
? { name: id, backend: payload.backend }
|
|
: this.normalizeSecrets(payload);
|
|
const { modelName } = primaryModelClass;
|
|
let transformedPayload = { [modelName]: secrets };
|
|
// just return the single object because ember is picky
|
|
if (requestType === 'queryRecord') {
|
|
transformedPayload = { [modelName]: secrets[0] };
|
|
}
|
|
|
|
return this._super(store, primaryModelClass, transformedPayload, id, requestType);
|
|
},
|
|
|
|
serialize(snapshot, requestType) {
|
|
if (requestType === 'update') {
|
|
const min_decryption_version = snapshot.attr('minDecryptionVersion');
|
|
const min_encryption_version = snapshot.attr('minEncryptionVersion');
|
|
const deletion_allowed = snapshot.attr('deletionAllowed');
|
|
const auto_rotate_interval = snapshot.attr('autoRotateInterval');
|
|
return {
|
|
min_decryption_version,
|
|
min_encryption_version,
|
|
deletion_allowed,
|
|
auto_rotate_interval,
|
|
};
|
|
} else {
|
|
snapshot.id = snapshot.attr('name');
|
|
return this._super(snapshot, requestType);
|
|
}
|
|
},
|
|
});
|