diff --git a/ui/app/adapters/secret-engine.js b/ui/app/adapters/secret-engine.js index c19b68b3fb..685707453f 100644 --- a/ui/app/adapters/secret-engine.js +++ b/ui/app/adapters/secret-engine.js @@ -87,13 +87,6 @@ export default ApplicationAdapter.extend({ } }, - findRecord(store, type, path, snapshot) { - if (snapshot.attr('type') === 'ssh') { - return this.ajax(`/v1/${encodePath(path)}/config/ca`, 'GET'); - } - return { data: {} }; - }, - queryRecord(store, type, query) { if (query.type === 'aws') { return this.ajax(`/v1/${encodePath(query.backend)}/config/lease`, 'GET').then((resp) => { diff --git a/ui/app/adapters/ssh/ca-config.js b/ui/app/adapters/ssh/ca-config.js index 1f89badf51..6f745a70a9 100644 --- a/ui/app/adapters/ssh/ca-config.js +++ b/ui/app/adapters/ssh/ca-config.js @@ -8,13 +8,39 @@ import { encodePath } from 'vault/utils/path-encoding-helpers'; export default class SshCaConfig extends ApplicationAdapter { namespace = 'v1'; - // For now this is only being used on the vault.cluster.secrets.backend.configuration route. This is a read-only route. - // Eventually, this will be used to create the ca config for the SSH secret backend, replacing the requests located on the secret-engine adapter. + queryRecord(store, type, query) { const { backend } = query; return this.ajax(`${this.buildURL()}/${encodePath(backend)}/config/ca`, 'GET').then((resp) => { resp.id = backend; + resp.backend = backend; return resp; }); } + + createOrUpdate(store, type, snapshot) { + const serializer = store.serializerFor(type.modelName); + const data = serializer.serialize(snapshot); + const backend = snapshot.record.backend; + return this.ajax(`${this.buildURL()}/${backend}/config/ca`, 'POST', { data }).then((resp) => { + // ember data requires an id on the response + return { + ...resp, + id: backend, + }; + }); + } + + createRecord() { + return this.createOrUpdate(...arguments); + } + + updateRecord() { + return this.createOrUpdate(...arguments); + } + + deleteRecord(store, type, snapshot) { + const backend = snapshot.record.backend; + return this.ajax(`${this.buildURL()}/${backend}/config/ca`, 'DELETE'); + } } diff --git a/ui/app/components/secret-engine/configuration-details.hbs b/ui/app/components/secret-engine/configuration-details.hbs index 9ed62214dd..a65b7cb39b 100644 --- a/ui/app/components/secret-engine/configuration-details.hbs +++ b/ui/app/components/secret-engine/configuration-details.hbs @@ -6,13 +6,14 @@ {{#if @configModels.length}} {{#each @configModels as |configModel|}} {{#each configModel.attrs as |attr|}} - {{#if attr.options.sensitive}} + {{! public key while not sensitive when editing/creating, should be hidden by default on viewing }} + {{#if (or attr.options.sensitive (eq attr.name "publicKey"))}} - {{#if attr.options.sensitive}} + {{#if (or attr.options.sensitive (eq attr.name "publicKey"))}} -
- +
+
+ + + {{#unless @model.isNew}} +

+ NOTE: You must delete your existing certificate and key before saving new values. +

+ {{/unless}} +
+ {{#if @model.isNew}} +
+ {{#each @model.formFields as |attr|}} + + {{/each}} +
+
- +
+ {{#if this.invalidFormAlert}} + + {{/if}}
-
-
- - - - -
-{{else}} - -
- -
- -
- -
-
+ {{else}} + {{! Model is not new and keys have already been created. Require user deletes the keys before creating new ones }} +
-