7bf3476be9
* remove unused response-wrapping route and controller
* move to using the internal mounts endpoint for the secrets list and individual engine lookup
* remove errors about sys/mounts access because we don't need it anymore 🎉
* use modelFor instead of peekRecord for looking up the secret-engine
* remove test because we removed that error page - in the worst case scenario, a user will only have access to cubbyhole, but will see that in the secrets engines list
* make the dev CSP the same as the Go CSP
* update serializer to handle SSH responses as well as new engine fetches
* back out some changes to ttl-picker and field test object so that tests pass
* get rid of trailing space in the secret engine link
* add secrets-engine adapater tests for new query behavior
88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
import Ember from 'ember';
|
|
import ApplicationAdapter from './application';
|
|
|
|
export default ApplicationAdapter.extend({
|
|
url(path) {
|
|
const url = `${this.buildURL()}/mounts`;
|
|
return path ? url + '/' + path : url;
|
|
},
|
|
|
|
pathForType() {
|
|
return 'mounts';
|
|
},
|
|
|
|
query(store, type, query) {
|
|
let url = `/${this.urlPrefix()}/internal/ui/mounts`;
|
|
if (query.path) {
|
|
url = `${url}/${query.path}`;
|
|
}
|
|
return this.ajax(url, 'GET');
|
|
},
|
|
|
|
createRecord(store, type, snapshot) {
|
|
const serializer = store.serializerFor(type.modelName);
|
|
const data = serializer.serialize(snapshot);
|
|
const path = snapshot.attr('path');
|
|
|
|
return this.ajax(this.url(path), 'POST', { data }).then(() => {
|
|
// ember data doesn't like 204s if it's not a DELETE
|
|
return {
|
|
data: Ember.assign({}, data, { path: path + '/', id: path }),
|
|
};
|
|
});
|
|
},
|
|
|
|
findRecord(store, type, path, snapshot) {
|
|
if (snapshot.attr('type') === 'ssh') {
|
|
return this.ajax(`/v1/${path}/config/ca`, 'GET');
|
|
}
|
|
return;
|
|
},
|
|
|
|
queryRecord(store, type, query) {
|
|
if (query.type === 'aws') {
|
|
return this.ajax(`/v1/${query.backend}/config/lease`, 'GET').then(resp => {
|
|
resp.path = query.backend + '/';
|
|
return resp;
|
|
});
|
|
}
|
|
return;
|
|
},
|
|
|
|
updateRecord(store, type, snapshot) {
|
|
const { apiPath, options, adapterMethod } = snapshot.adapterOptions;
|
|
if (adapterMethod) {
|
|
return this[adapterMethod](...arguments);
|
|
}
|
|
if (apiPath) {
|
|
const serializer = store.serializerFor(type.modelName);
|
|
const data = serializer.serialize(snapshot);
|
|
const path = snapshot.id;
|
|
return this.ajax(`/v1/${path}/${apiPath}`, options.isDelete ? 'DELETE' : 'POST', { data });
|
|
}
|
|
},
|
|
|
|
saveAWSRoot(store, type, snapshot) {
|
|
let { data } = snapshot.adapterOptions;
|
|
const path = snapshot.id;
|
|
return this.ajax(`/v1/${path}/config/root`, 'POST', { data });
|
|
},
|
|
|
|
saveAWSLease(store, type, snapshot) {
|
|
let { data } = snapshot.adapterOptions;
|
|
const path = snapshot.id;
|
|
return this.ajax(`/v1/${path}/config/lease`, 'POST', { data });
|
|
},
|
|
|
|
saveZeroAddressConfig(store, type, snapshot) {
|
|
const path = snapshot.id;
|
|
const roles = store.peekAll('role-ssh').filterBy('zeroAddress').mapBy('id').join(',');
|
|
const url = `/v1/${path}/config/zeroaddress`;
|
|
const data = { roles };
|
|
if (roles === '') {
|
|
return this.ajax(url, 'DELETE');
|
|
}
|
|
return this.ajax(url, 'POST', { data });
|
|
},
|
|
});
|