mirror of
https://github.com/hashicorp/vault.git
synced 2025-09-01 12:01:10 +02:00
PKI cleanup continued: queryParams and moving routes/models/serializers to pki folder (#15980)
* routing params * wip for cert * move pki-config * clean up
This commit is contained in:
parent
531abac2c1
commit
a638b08ae0
@ -2,7 +2,7 @@ import AdapterError from '@ember-data/adapter/error';
|
|||||||
import { hash, resolve } from 'rsvp';
|
import { hash, resolve } from 'rsvp';
|
||||||
import { capitalize } from '@ember/string';
|
import { capitalize } from '@ember/string';
|
||||||
import { set } from '@ember/object';
|
import { set } from '@ember/object';
|
||||||
import ApplicationAdapter from './application';
|
import ApplicationAdapter from '../application';
|
||||||
|
|
||||||
export default ApplicationAdapter.extend({
|
export default ApplicationAdapter.extend({
|
||||||
namespace: 'v1',
|
namespace: 'v1',
|
@ -16,7 +16,7 @@ const MODEL_TYPES = {
|
|||||||
backIsListLink: true,
|
backIsListLink: true,
|
||||||
},
|
},
|
||||||
'pki-issue': {
|
'pki-issue': {
|
||||||
model: 'pki/pki-certificate',
|
model: 'pki/cert',
|
||||||
title: 'Issue Certificate',
|
title: 'Issue Certificate',
|
||||||
},
|
},
|
||||||
'pki-sign': {
|
'pki-sign': {
|
||||||
|
@ -34,13 +34,13 @@ const SECRET_BACKENDS = {
|
|||||||
editComponent: 'pki/role-pki-edit',
|
editComponent: 'pki/role-pki-edit',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'certs',
|
name: 'cert',
|
||||||
modelPrefix: 'cert/',
|
modelPrefix: 'cert/',
|
||||||
label: 'Certificates',
|
label: 'Certificates',
|
||||||
searchPlaceholder: 'Filter certificates',
|
searchPlaceholder: 'Filter certificates',
|
||||||
item: 'certificates',
|
item: 'certificates',
|
||||||
create: 'Create role',
|
create: 'Create role',
|
||||||
tab: 'certs',
|
tab: 'cert',
|
||||||
listItemPartial: 'secret-list/pki-cert-item',
|
listItemPartial: 'secret-list/pki-cert-item',
|
||||||
editComponent: 'pki/pki-cert-show',
|
editComponent: 'pki/pki-cert-show',
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { attr } from '@ember-data/model';
|
import { attr } from '@ember-data/model';
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
import Certificate from './pki/pki-certificate';
|
import Certificate from './pki/cert';
|
||||||
|
|
||||||
export default Certificate.extend({
|
export default Certificate.extend({
|
||||||
DISPLAY_FIELDS: computed(function () {
|
DISPLAY_FIELDS: computed(function () {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { attr } from '@ember-data/model';
|
import { attr } from '@ember-data/model';
|
||||||
import { copy } from 'ember-copy';
|
import { copy } from 'ember-copy';
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
import Certificate from './pki/pki-certificate';
|
import Certificate from './pki/cert';
|
||||||
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs';
|
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs';
|
||||||
|
|
||||||
export default Certificate.extend({
|
export default Certificate.extend({
|
||||||
|
@ -80,7 +80,7 @@ export default Route.extend({
|
|||||||
ssh: 'role-ssh',
|
ssh: 'role-ssh',
|
||||||
transform: this.modelTypeForTransform(tab),
|
transform: this.modelTypeForTransform(tab),
|
||||||
aws: 'role-aws',
|
aws: 'role-aws',
|
||||||
pki: tab === 'certs' ? 'pki/pki-certificate' : 'pki/pki-role',
|
pki: `pki/${tab || 'pki-role'}`,
|
||||||
// secret or secret-v2
|
// secret or secret-v2
|
||||||
cubbyhole: 'secret',
|
cubbyhole: 'secret',
|
||||||
kv: secretEngine.get('modelTypeForKV'),
|
kv: secretEngine.get('modelTypeForKV'),
|
||||||
@ -130,7 +130,7 @@ export default Route.extend({
|
|||||||
afterModel(model) {
|
afterModel(model) {
|
||||||
const { tab } = this.paramsFor(this.routeName);
|
const { tab } = this.paramsFor(this.routeName);
|
||||||
const backend = this.enginePathParam();
|
const backend = this.enginePathParam();
|
||||||
if (!tab || tab !== 'certs') {
|
if (!tab || tab !== 'cert') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return all(
|
return all(
|
||||||
@ -138,7 +138,7 @@ export default Route.extend({
|
|||||||
// possible that there is no certificate for them in order to know,
|
// possible that there is no certificate for them in order to know,
|
||||||
// we fetch them specifically on the list page, and then unload the
|
// we fetch them specifically on the list page, and then unload the
|
||||||
// records if there is no `certificate` attribute on the resultant model
|
// records if there is no `certificate` attribute on the resultant model
|
||||||
['ca', 'crl', 'ca_chain'].map((id) => this.store.queryRecord('pki/pki-certificate', { id, backend }))
|
['ca', 'crl', 'ca_chain'].map((id) => this.store.queryRecord('pki/cert', { id, backend }))
|
||||||
).then(
|
).then(
|
||||||
(results) => {
|
(results) => {
|
||||||
results.rejectBy('certificate').forEach((record) => record.unloadRecord());
|
results.rejectBy('certificate').forEach((record) => record.unloadRecord());
|
||||||
|
@ -101,7 +101,7 @@ export default Route.extend(UnloadModelRoute, {
|
|||||||
ssh: 'role-ssh',
|
ssh: 'role-ssh',
|
||||||
transform: this.modelTypeForTransform(secret),
|
transform: this.modelTypeForTransform(secret),
|
||||||
aws: 'role-aws',
|
aws: 'role-aws',
|
||||||
pki: secret && secret.startsWith('cert/') ? 'pki/pki-certificate' : 'pki/pki-role',
|
pki: secret && secret.startsWith('cert/') ? 'pki/cert' : 'pki/pki-role',
|
||||||
cubbyhole: 'secret',
|
cubbyhole: 'secret',
|
||||||
kv: backendModel.get('modelTypeForKV'),
|
kv: backendModel.get('modelTypeForKV'),
|
||||||
keymgmt: `keymgmt/${options.queryParams?.itemType || 'key'}`,
|
keymgmt: `keymgmt/${options.queryParams?.itemType || 'key'}`,
|
||||||
@ -230,7 +230,7 @@ export default Route.extend(UnloadModelRoute, {
|
|||||||
if (!secret) {
|
if (!secret) {
|
||||||
secret = '\u0020';
|
secret = '\u0020';
|
||||||
}
|
}
|
||||||
if (modelType === 'pki/pki-certificate') {
|
if (modelType === 'pki/cert') {
|
||||||
secret = secret.replace('cert/', '');
|
secret = secret.replace('cert/', '');
|
||||||
}
|
}
|
||||||
if (modelType.startsWith('transform/')) {
|
if (modelType.startsWith('transform/')) {
|
||||||
|
@ -2,6 +2,7 @@ import AdapterError from '@ember-data/adapter/error';
|
|||||||
import { set } from '@ember/object';
|
import { set } from '@ember/object';
|
||||||
import Route from '@ember/routing/route';
|
import Route from '@ember/routing/route';
|
||||||
|
|
||||||
|
// ARG TODO glimmerize
|
||||||
const SECTIONS_FOR_TYPE = {
|
const SECTIONS_FOR_TYPE = {
|
||||||
pki: ['cert', 'urls', 'crl', 'tidy'],
|
pki: ['cert', 'urls', 'crl', 'tidy'],
|
||||||
};
|
};
|
||||||
@ -9,14 +10,21 @@ export default Route.extend({
|
|||||||
fetchModel() {
|
fetchModel() {
|
||||||
const { section_name: sectionName } = this.paramsFor(this.routeName);
|
const { section_name: sectionName } = this.paramsFor(this.routeName);
|
||||||
const backendModel = this.modelFor('vault.cluster.settings.configure-secret-backend');
|
const backendModel = this.modelFor('vault.cluster.settings.configure-secret-backend');
|
||||||
const modelType = `${backendModel.get('type')}-config`;
|
const type = backendModel.get('type');
|
||||||
|
let modelType;
|
||||||
|
if (type === 'pki') {
|
||||||
|
// pki models are in models/pki
|
||||||
|
modelType = `${type}/${type}-config`;
|
||||||
|
} else {
|
||||||
|
modelType = `${type}-config`;
|
||||||
|
}
|
||||||
return this.store
|
return this.store
|
||||||
.queryRecord(modelType, {
|
.queryRecord(modelType, {
|
||||||
backend: backendModel.id,
|
backend: backendModel.id,
|
||||||
section: sectionName,
|
section: sectionName,
|
||||||
})
|
})
|
||||||
.then((model) => {
|
.then((model) => {
|
||||||
model.set('backendType', backendModel.get('type'));
|
model.set('backendType', type);
|
||||||
model.set('section', sectionName);
|
model.set('section', sectionName);
|
||||||
return model;
|
return model;
|
||||||
});
|
});
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
</CopyButton>
|
</CopyButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<LinkTo @route="vault.cluster.secrets.backend.list-root" @query={{hash tab="certs"}} class="button">
|
<LinkTo @route="vault.cluster.secrets.backend.list-root" @query={{hash tab="cert"}} class="button">
|
||||||
Back
|
Back
|
||||||
</LinkTo>
|
</LinkTo>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<SecretListHeader
|
<SecretListHeader
|
||||||
@isCertTab={{eq this.tab "certs"}}
|
@isCertTab={{eq this.tab "cert"}}
|
||||||
@model={{this.backendModel}}
|
@model={{this.backendModel}}
|
||||||
@baseKey={{this.baseKey}}
|
@baseKey={{this.baseKey}}
|
||||||
@backendCrumb={{this.backendCrumb}}
|
@backendCrumb={{this.backendCrumb}}
|
||||||
@ -49,7 +49,7 @@
|
|||||||
@baseKey={{get this.baseKey "id"}}
|
@baseKey={{get this.baseKey "id"}}
|
||||||
@shouldNavigateTree={{options.navigateTree}}
|
@shouldNavigateTree={{options.navigateTree}}
|
||||||
@placeholder={{options.searchPlaceholder}}
|
@placeholder={{options.searchPlaceholder}}
|
||||||
@mode={{if (eq this.tab "certs") "secrets-cert" "secrets"}}
|
@mode={{if (eq this.tab "cert") "secrets-cert" "secrets"}}
|
||||||
/>
|
/>
|
||||||
{{#if this.filterFocused}}
|
{{#if this.filterFocused}}
|
||||||
{{#if this.filterMatchesKey}}
|
{{#if this.filterMatchesKey}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<SecretListHeader
|
<SecretListHeader
|
||||||
@isCertTab={{eq this.tab "certs"}}
|
@isCertTab={{eq this.tab "cert"}}
|
||||||
@model={{this.model}}
|
@model={{this.model}}
|
||||||
@baseKey={{this.baseKey}}
|
@baseKey={{this.baseKey}}
|
||||||
@backendCrumb={{this.backendCrumb}}
|
@backendCrumb={{this.backendCrumb}}
|
||||||
|
@ -9,7 +9,7 @@ import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
|
|||||||
import authPage from 'vault/tests/pages/auth';
|
import authPage from 'vault/tests/pages/auth';
|
||||||
import { SELECTORS } from 'vault/tests/helpers/pki';
|
import { SELECTORS } from 'vault/tests/helpers/pki';
|
||||||
|
|
||||||
module('Acceptance | secrets/pki/list?tab=certs', function (hooks) {
|
module('Acceptance | secrets/pki/list?tab=cert', function (hooks) {
|
||||||
setupApplicationTest(hooks);
|
setupApplicationTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
@ -88,7 +88,7 @@ elRplAzrMF4=
|
|||||||
const path = await setup(assert);
|
const path = await setup(assert);
|
||||||
await generatePage.issueCert('foo');
|
await generatePage.issueCert('foo');
|
||||||
await settled();
|
await settled();
|
||||||
await listPage.visitRoot({ backend: path, tab: 'certs' });
|
await listPage.visitRoot({ backend: path, tab: 'cert' });
|
||||||
await settled();
|
await settled();
|
||||||
assert.ok(listPage.secrets.length > 0, 'lists certs');
|
assert.ok(listPage.secrets.length > 0, 'lists certs');
|
||||||
await listPage.secrets.objectAt(0).click();
|
await listPage.secrets.objectAt(0).click();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user