mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-13 14:51:34 +01:00
Co-authored-by: Shannon Roberts (Beagin) <beagins@users.noreply.github.com>
This commit is contained in:
parent
f2872f0cc7
commit
d173b10eb1
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) HashiCorp, Inc.
|
|
||||||
* SPDX-License-Identifier: BUSL-1.1
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { service } from '@ember/service';
|
|
||||||
import Controller from '@ember/controller';
|
|
||||||
import { action } from '@ember/object';
|
|
||||||
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
|
|
||||||
import engineDisplayData from 'vault/helpers/engines-display-data';
|
|
||||||
|
|
||||||
const SUPPORTED_BACKENDS = supportedSecretBackends();
|
|
||||||
|
|
||||||
export default class MountSecretBackendController extends Controller {
|
|
||||||
@service router;
|
|
||||||
|
|
||||||
@action
|
|
||||||
onMountSuccess(type, path, useEngineRoute = false) {
|
|
||||||
let transition;
|
|
||||||
if (SUPPORTED_BACKENDS.includes(type)) {
|
|
||||||
const engineInfo = engineDisplayData(type);
|
|
||||||
if (useEngineRoute) {
|
|
||||||
transition = this.router.transitionTo(
|
|
||||||
`vault.cluster.secrets.backend.${engineInfo.engineRoute}`,
|
|
||||||
path
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// For keymgmt, we need to land on provider tab by default using query params
|
|
||||||
const queryParams = engineInfo.type === 'keymgmt' ? { tab: 'provider' } : {};
|
|
||||||
transition = this.router.transitionTo('vault.cluster.secrets.backend.index', path, { queryParams });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
transition = this.router.transitionTo('vault.cluster.secrets.backends');
|
|
||||||
}
|
|
||||||
return transition.followRedirects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -60,7 +60,6 @@ Router.map(function () {
|
|||||||
this.route('section', { path: '/:section_name' });
|
this.route('section', { path: '/:section_name' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.route('mount-secret-backend');
|
|
||||||
});
|
});
|
||||||
this.route('unseal');
|
this.route('unseal');
|
||||||
this.route('tools', function () {
|
this.route('tools', function () {
|
||||||
|
|||||||
@ -5,8 +5,10 @@
|
|||||||
|
|
||||||
import Route from '@ember/routing/route';
|
import Route from '@ember/routing/route';
|
||||||
import { service } from '@ember/service';
|
import { service } from '@ember/service';
|
||||||
|
import { hash } from 'rsvp';
|
||||||
import SecretsEngineForm from 'vault/forms/secrets/engine';
|
import SecretsEngineForm from 'vault/forms/secrets/engine';
|
||||||
import Router from 'vault/router';
|
import Router from 'vault/router';
|
||||||
|
import type PluginCatalogService from 'vault/services/plugin-catalog';
|
||||||
|
|
||||||
import type { ModelFrom } from 'vault/vault/route';
|
import type { ModelFrom } from 'vault/vault/route';
|
||||||
|
|
||||||
@ -14,8 +16,9 @@ export type MountSecretBackendModel = ModelFrom<VaultClusterSecretsMountsIndexRo
|
|||||||
|
|
||||||
export default class VaultClusterSecretsMountsIndexRouter extends Route {
|
export default class VaultClusterSecretsMountsIndexRouter extends Route {
|
||||||
@service declare router: Router;
|
@service declare router: Router;
|
||||||
|
@service('plugin-catalog') declare readonly pluginCatalog: PluginCatalogService;
|
||||||
|
|
||||||
model() {
|
async model() {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
config: { listing_visibility: false },
|
config: { listing_visibility: false },
|
||||||
kv_config: {
|
kv_config: {
|
||||||
@ -25,6 +28,16 @@ export default class VaultClusterSecretsMountsIndexRouter extends Route {
|
|||||||
},
|
},
|
||||||
options: { version: 2 },
|
options: { version: 2 },
|
||||||
};
|
};
|
||||||
return new SecretsEngineForm(defaults, { isNew: true });
|
|
||||||
|
const secretEngineForm = new SecretsEngineForm(defaults, { isNew: true });
|
||||||
|
|
||||||
|
// Fetch plugin catalog data to enhance the secret engines list
|
||||||
|
const pluginCatalogResponse = await this.pluginCatalog.fetchPluginCatalog();
|
||||||
|
|
||||||
|
return hash({
|
||||||
|
form: secretEngineForm,
|
||||||
|
pluginCatalogData: pluginCatalogResponse.data,
|
||||||
|
pluginCatalogError: pluginCatalogResponse.error,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,10 +9,7 @@ import { service } from '@ember/service';
|
|||||||
export default class SettingsIndexRouter extends Route {
|
export default class SettingsIndexRouter extends Route {
|
||||||
@service router;
|
@service router;
|
||||||
|
|
||||||
beforeModel(transition) {
|
redirect() {
|
||||||
if (transition.targetName === this.routeName) {
|
return this.router.replaceWith('vault.cluster.secrets.mounts.index');
|
||||||
transition.abort();
|
|
||||||
return this.router.replaceWith('vault.cluster.settings.mount-secret-backend');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) HashiCorp, Inc.
|
|
||||||
* SPDX-License-Identifier: BUSL-1.1
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Route from '@ember/routing/route';
|
|
||||||
import SecretsEngineForm from 'vault/forms/secrets/engine';
|
|
||||||
import { service } from '@ember/service';
|
|
||||||
import { hash } from 'rsvp';
|
|
||||||
|
|
||||||
import type { ModelFrom } from 'vault/vault/route';
|
|
||||||
import type AuthService from 'vault/services/auth';
|
|
||||||
import type NamespaceService from 'vault/services/namespace';
|
|
||||||
import type PluginCatalogService from 'vault/services/plugin-catalog';
|
|
||||||
|
|
||||||
export type MountSecretBackendModel = ModelFrom<VaultClusterSettingsMountSecretBackendRoute>;
|
|
||||||
|
|
||||||
export default class VaultClusterSettingsMountSecretBackendRoute extends Route {
|
|
||||||
@service declare readonly auth: AuthService;
|
|
||||||
@service declare readonly namespace: NamespaceService;
|
|
||||||
@service('plugin-catalog') declare readonly pluginCatalog: PluginCatalogService;
|
|
||||||
|
|
||||||
async model() {
|
|
||||||
const defaults = {
|
|
||||||
config: { listing_visibility: false },
|
|
||||||
kv_config: {
|
|
||||||
max_versions: 0,
|
|
||||||
cas_required: false,
|
|
||||||
delete_version_after: undefined,
|
|
||||||
},
|
|
||||||
options: { version: 2 },
|
|
||||||
};
|
|
||||||
|
|
||||||
const secretEngineForm = new SecretsEngineForm(defaults, { isNew: true });
|
|
||||||
|
|
||||||
// Fetch plugin catalog data to enhance the secret engines list
|
|
||||||
const pluginCatalogResponse = await this.pluginCatalog.fetchPluginCatalog();
|
|
||||||
|
|
||||||
return hash({
|
|
||||||
form: secretEngineForm,
|
|
||||||
pluginCatalogData: pluginCatalogResponse.data,
|
|
||||||
pluginCatalogError: pluginCatalogResponse.error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
{{!
|
|
||||||
Copyright (c) HashiCorp, Inc.
|
|
||||||
SPDX-License-Identifier: BUSL-1.1
|
|
||||||
}}
|
|
||||||
|
|
||||||
<MountBackendForm @mountModel={{this.model}} @mountCategory="secret" @onMountSuccess={{action "onMountSuccess"}} />
|
|
||||||
@ -39,7 +39,7 @@ const consoleComponent = create(consoleClass);
|
|||||||
|
|
||||||
// enterprise backends are tested separately
|
// enterprise backends are tested separately
|
||||||
const BACKENDS_WITH_ENGINES = ['kv', 'pki', 'ldap', 'kubernetes'];
|
const BACKENDS_WITH_ENGINES = ['kv', 'pki', 'ldap', 'kubernetes'];
|
||||||
module('Acceptance | settings/mount-secret-backend', function (hooks) {
|
module('Acceptance | secrets/mounts', function (hooks) {
|
||||||
setupApplicationTest(hooks);
|
setupApplicationTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
Loading…
x
Reference in New Issue
Block a user