open-vault/ui/app/routes/vault/cluster/settings/configure-secret-backend.js
Matthew Irish 7bf3476be9
Ui kv preflight endpoints (#4439)
* 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
2018-04-24 16:30:44 -05:00

66 lines
1.5 KiB
JavaScript

import Ember from 'ember';
import DS from 'ember-data';
const CONFIGURABLE_BACKEND_TYPES = ['aws', 'ssh', 'pki'];
export default Ember.Route.extend({
model() {
const { backend } = this.paramsFor(this.routeName);
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 DS.AdapterError();
Ember.set(error, 'httpStatus', 404);
throw error;
}
return this.store.findRecord('secret-engine', backend).then(
() => {
return model;
},
() => {
return model;
}
);
});
},
afterModel(model, transition) {
const type = model.get('type');
if (type === 'pki') {
if (transition.targetName === this.routeName) {
return this.transitionTo(`${this.routeName}.section`, 'cert');
} else {
return;
}
}
if (type === 'aws') {
return this.store
.queryRecord('secret-engine', {
backend: model.id,
type,
})
.then(() => model, () => model);
}
return model;
},
setupController(controller, model) {
if (model.get('publicKey')) {
controller.set('configured', true);
}
return this._super(...arguments);
},
resetController(controller, isExiting) {
if (isExiting) {
controller.reset();
}
},
actions: {
refreshRoute() {
this.refresh();
},
},
});