diff --git a/ui/app/adapters/pki/crl.js b/ui/app/adapters/pki/config/base.js similarity index 59% rename from ui/app/adapters/pki/crl.js rename to ui/app/adapters/pki/config/base.js index 037601a82..a655d09cf 100644 --- a/ui/app/adapters/pki/crl.js +++ b/ui/app/adapters/pki/config/base.js @@ -3,16 +3,11 @@ * SPDX-License-Identifier: MPL-2.0 */ -import { encodePath } from 'vault/utils/path-encoding-helpers'; -import ApplicationAdapter from '../application'; +import ApplicationAdapter from '../../application'; -export default class PkiCrlAdapter extends ApplicationAdapter { +export default class PkiConfigBaseAdapter extends ApplicationAdapter { namespace = 'v1'; - _url(backend) { - return `${this.buildURL()}/${encodePath(backend)}/config/crl`; - } - findRecord(store, type, backend) { return this.ajax(this._url(backend), 'GET').then((resp) => { return resp.data; diff --git a/ui/app/adapters/pki/config/cluster.js b/ui/app/adapters/pki/config/cluster.js new file mode 100644 index 000000000..aa164261c --- /dev/null +++ b/ui/app/adapters/pki/config/cluster.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import { encodePath } from 'vault/utils/path-encoding-helpers'; +import PkiConfigBaseAdapter from './base'; + +export default class PkiConfigClusterAdapter extends PkiConfigBaseAdapter { + namespace = 'v1'; + + _url(backend) { + return `${this.buildURL()}/${encodePath(backend)}/config/cluster`; + } +} diff --git a/ui/app/adapters/pki/config/crl.js b/ui/app/adapters/pki/config/crl.js new file mode 100644 index 000000000..d7e5dc839 --- /dev/null +++ b/ui/app/adapters/pki/config/crl.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import { encodePath } from 'vault/utils/path-encoding-helpers'; +import PkiConfigBaseAdapter from './base'; + +export default class PkiConfigCrlAdapter extends PkiConfigBaseAdapter { + namespace = 'v1'; + + _url(backend) { + return `${this.buildURL()}/${encodePath(backend)}/config/crl`; + } +} diff --git a/ui/app/adapters/pki/config/urls.js b/ui/app/adapters/pki/config/urls.js new file mode 100644 index 000000000..ae15f5959 --- /dev/null +++ b/ui/app/adapters/pki/config/urls.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import { encodePath } from 'vault/utils/path-encoding-helpers'; +import PkiConfigBaseAdapter from './base'; + +export default class PkiConfigUrlsAdapter extends PkiConfigBaseAdapter { + namespace = 'v1'; + + _url(backend) { + return `${this.buildURL()}/${encodePath(backend)}/config/urls`; + } +} diff --git a/ui/app/adapters/pki/urls.js b/ui/app/adapters/pki/urls.js deleted file mode 100644 index 18f768b1c..000000000 --- a/ui/app/adapters/pki/urls.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { encodePath } from 'vault/utils/path-encoding-helpers'; -import ApplicationAdapter from '../application'; - -export default class PkiUrlsAdapter extends ApplicationAdapter { - namespace = 'v1'; - - _url(backend) { - return `${this.buildURL()}/${encodePath(backend)}/config/urls`; - } - - updateRecord(store, type, snapshot) { - const data = snapshot.serialize(); - return this.ajax(this._url(snapshot.record.id), 'POST', { data }); - } - - urlForFindRecord(id) { - return this._url(id); - } -} diff --git a/ui/app/models/pki/config/cluster.js b/ui/app/models/pki/config/cluster.js new file mode 100644 index 000000000..74c614f49 --- /dev/null +++ b/ui/app/models/pki/config/cluster.js @@ -0,0 +1,40 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import Model, { attr } from '@ember-data/model'; +import { withFormFields } from 'vault/decorators/model-form-fields'; +import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; + +@withFormFields() +export default class PkiConfigClusterModel extends Model { + // This model uses the backend value as the model ID + get useOpenAPI() { + return true; + } + + getHelpUrl(backendPath) { + return `/v1/${backendPath}/config/cluster?help=1`; + } + + @attr('string', { + label: "Mount's API path", + subText: + "Specifies the path to this performance replication cluster's API mount path, including any namespaces as path components. This address is used for the ACME directories, which must be served over a TLS-enabled listener.", + }) + path; + @attr('string', { + label: 'AIA path', + subText: + "Specifies the path to this performance replication cluster's AIA distribution point; may refer to an external, non-Vault responder.", + }) + aiaPath; + + // this is for pki-only cluster config, not the universal vault cluster + @lazyCapabilities(apiPath`${'id'}/config/cluster`, 'id') clusterPath; + + get canSet() { + return this.clusterPath.get('canCreate') !== false; + } +} diff --git a/ui/app/models/pki/crl.js b/ui/app/models/pki/config/crl.js similarity index 98% rename from ui/app/models/pki/crl.js rename to ui/app/models/pki/config/crl.js index 55030c3d5..6d7490e3b 100644 --- a/ui/app/models/pki/crl.js +++ b/ui/app/models/pki/config/crl.js @@ -17,7 +17,7 @@ const formFieldGroups = [ { 'Unified Revocation': ['crossClusterRevocation', 'unifiedCrl', 'unifiedCrlOnExistingPaths'] }, ]; @withFormFields(null, formFieldGroups) -export default class PkiCrlModel extends Model { +export default class PkiConfigCrlModel extends Model { // This model uses the backend value as the model ID @attr('boolean') autoRebuild; diff --git a/ui/app/models/pki/urls.js b/ui/app/models/pki/config/urls.js similarity index 95% rename from ui/app/models/pki/urls.js rename to ui/app/models/pki/config/urls.js index 76bfa7e22..ade9b8450 100644 --- a/ui/app/models/pki/urls.js +++ b/ui/app/models/pki/config/urls.js @@ -8,7 +8,7 @@ import { withFormFields } from 'vault/decorators/model-form-fields'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; @withFormFields() -export default class PkiUrlsModel extends Model { +export default class PkiConfigUrlsModel extends Model { // This model uses the backend value as the model ID get useOpenAPI() { return true; diff --git a/ui/lib/pki/addon/components/page/pki-configuration-details.hbs b/ui/lib/pki/addon/components/page/pki-configuration-details.hbs index aa047999e..d6920bdfd 100644 --- a/ui/lib/pki/addon/components/page/pki-configuration-details.hbs +++ b/ui/lib/pki/addon/components/page/pki-configuration-details.hbs @@ -23,8 +23,20 @@ + {{#if (not (eq @cluster 403))}} +

+ Cluster Config +

+ {{#each @cluster.allFields as |attr|}} + + {{/each}} + {{/if}} + {{#if (not (eq @urls 403))}} -

+

Global URLs

diff --git a/ui/lib/pki/addon/components/page/pki-configuration-details.ts b/ui/lib/pki/addon/components/page/pki-configuration-details.ts index fa849d139..5f88e98e1 100644 --- a/ui/lib/pki/addon/components/page/pki-configuration-details.ts +++ b/ui/lib/pki/addon/components/page/pki-configuration-details.ts @@ -14,7 +14,7 @@ import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; interface Args { - currentPath: string; + backend: string; } export default class PkiConfigurationDetails extends Component { @@ -32,7 +32,7 @@ export default class PkiConfigurationDetails extends Component { async deleteAllIssuers() { try { const issuerAdapter = this.store.adapterFor('pki/issuer'); - await issuerAdapter.deleteAllIssuers(this.args.currentPath); + await issuerAdapter.deleteAllIssuers(this.args.backend); this.flashMessages.success('Successfully deleted all issuers and keys'); this.showDeleteAllIssuers = false; this.router.transitionTo('vault.cluster.secrets.backend.pki.configuration.index'); diff --git a/ui/lib/pki/addon/components/page/pki-configuration-edit.hbs b/ui/lib/pki/addon/components/page/pki-configuration-edit.hbs index 2e211d6c5..315c4455f 100644 --- a/ui/lib/pki/addon/components/page/pki-configuration-edit.hbs +++ b/ui/lib/pki/addon/components/page/pki-configuration-edit.hbs @@ -3,6 +3,25 @@ {{/if}}
+
+ + {{#if @cluster.canSet}} + {{#each @cluster.allFields as |attr|}} + + {{/each}} + {{else}} + + POST /{{@backend}}/config/cluster + + {{/if}} +
+