open-vault/ui/app/routes/vault/cluster/secrets/backend/sign.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

45 lines
1.2 KiB
JavaScript

import Ember from 'ember';
import UnloadModel from 'vault/mixins/unload-model-route';
export default Ember.Route.extend(UnloadModel, {
templateName: 'vault/cluster/secrets/backend/sign',
backendModel() {
return this.modelFor('vault.cluster.secrets.backend');
},
pathQuery(role, backend) {
return {
id: `${backend}/sign/${role}`,
};
},
model(params) {
const role = params.secret;
const backendModel = this.backendModel();
const backend = backendModel.get('id');
if (backendModel.get('type') !== 'ssh') {
return this.transitionTo('vault.cluster.secrets.backend.list-root', backend);
}
return this.store.queryRecord('capabilities', this.pathQuery(role, backend)).then(capabilities => {
if (!capabilities.get('canUpdate')) {
return this.transitionTo('vault.cluster.secrets.backend.list-root', backend);
}
return this.store.createRecord('ssh-sign', {
role: {
backend,
id: role,
name: role,
},
id: `${backend}-${role}`,
});
});
},
setupController(controller) {
this._super(...arguments);
controller.set('backend', this.backendModel());
},
});