Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
model(params) {
let { section } = params;
let itemType = this.modelFor('vault.cluster.access.identity') + '-alias';
let tabs = TABS[itemType];
let modelType = `identity/${itemType}`;
if (!tabs.includes(section)) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
// TODO peekRecord here to see if we have the record already
return hash({
model: this.store.findRecord(modelType, params.item_alias_id),
section,
});
},
model(params) {
let { section } = params;
let itemType = this.modelFor('vault.cluster.access.identity');
let tabs = TABS[itemType];
let modelType = `identity/${itemType}`;
if (!tabs.includes(section)) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
// if the record is in the store use that
let model = this.store.peekRecord(modelType, params.item_id);
// if we don't have creationTime, we only have a partial model so reload
if (model && !model.get('creationTime')) {
model = model.reload();
}
// if there's no model, we need to fetch it
if (!model) {
model = this.store.findRecord(modelType, params.item_id);
}
model(params) {
let model = MODEL_FROM_PARAM[params.item_type];
if (!model) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
return model;
},
});
model(params) {
const { section_name: section } = params;
if (section !== 'configuration') {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
let backend = this.modelFor('vault.cluster.access.method');
this.wizard.transitionFeatureMachine(this.wizard.featureState, 'DETAILS', backend.type);
return backend;
},
return this.store.findAll('auth-method').then(modelArray => {
const model = modelArray.findBy('id', path);
if (!model) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
return this.pathHelp.getPaths(model.apiPath, path).then(paths => {
model.set('paths', paths);
return model;
});
});
},
switch (status) {
case 401:
return new UnauthorizedError(errors, detailedMessage);
case 403:
return new ForbiddenError(errors, detailedMessage);
case 404:
return new NotFoundError(errors, detailedMessage);
case 409:
return new ConflictError(errors, detailedMessage);
default:
if (status >= 500) {
return new ServerError(errors, detailedMessage);
}
}
return new AdapterError(errors, detailedMessage);
},
error = new NotFoundError(errors, detailedMessage);
break;
case 408:
error = new TimeoutError();
break;
case 409:
error = new ConflictError(errors, detailedMessage);
break;
case 422:
error = new InvalidError(errors); //payload.errors
break;
default:
if (err.statusCode >= 500) {
error = new ServerError(errors, detailedMessage);
} else {
error = new AdapterError(errors, detailedMessage);
}
}
} catch (e) {
error = e;
}
throw error;
},
query: function(store, type, query) {
fetchSection(backendPath, section) {
const sections = ['cert', 'urls', 'crl', 'tidy'];
if (!section || !sections.includes(section)) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
return this[`fetch${capitalize(section)}`](backendPath);
},
model(params) {
const { section_name: sectionName } = params;
const backendModel = this.modelFor('vault.cluster.settings.configure-secret-backend');
const sections = SECTIONS_FOR_TYPE[backendModel.get('type')];
const hasSection = sections.includes(sectionName);
if (!backendModel || !hasSection) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
return this.fetchModel();
},
return this.store.query('secret-engine', { path: backend }).then(modelList => {
let model = modelList && modelList.get('firstObject');
if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) {
const error = new AdapterError();
set(error, 'httpStatus', 404);
throw error;
}
return this.store.findRecord('secret-engine', backend).then(
() => {
return model;
},
() => {
return model;
}
);
});
},