Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes redirects to KV engine when secret is a directory #24281

Merged
merged 8 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/24281.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Correctly handle directory redirects from pre 1.15.0 Kv v2 list view urls.
```
2 changes: 1 addition & 1 deletion ui/app/components/dashboard/quick-actions-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class DashboardQuickActionsCard extends Component {
@action
navigateToPage() {
let route = this.searchSelectParams.route;
// If search-select falls back to stringInput, paramVlue is a string not object
// If search-select falls back to stringInput, paramValue is a string not object
let param = this.paramValue.id || this.paramValue;

// kv has a special use case where if the paramValue ends in a '/' you should
Expand Down
4 changes: 4 additions & 0 deletions ui/app/routes/vault/cluster/secrets/backend/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { allEngines, isAddonEngine } from 'vault/helpers/mountable-secret-engine
import { inject as service } from '@ember/service';
import { normalizePath } from 'vault/utils/path-encoding-helpers';
import { assert } from '@ember/debug';
import { pathIsDirectory } from 'kv/utils/kv-breadcrumbs';

const SUPPORTED_BACKENDS = supportedSecretBackends();

Expand Down Expand Up @@ -77,6 +78,9 @@ export default Route.extend({
return this.router.replaceWith('vault.cluster.secrets.backend.list', secret + '/');
}
if (isAddonEngine(type, secretEngine.version)) {
if (engineRoute === 'kv.list' && pathIsDirectory(secret)) {
return this.router.transitionTo('vault.cluster.secrets.backend.kv.list-directory', backend, secret);
}
return this.router.transitionTo(`vault.cluster.secrets.backend.${engineRoute}`, backend);
}
const modelType = this.getModelType(backend, tab);
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I ran this same test on main and it fails, so this test is successfully testing this change.

Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ module('Acceptance | kv-v2 workflow | navigation', function (hooks) {
await click(PAGE.breadcrumbAtIdx(1));
assert.ok(currentURL().startsWith(`/vault/secrets/${backend}/kv/list`), 'links back to list root');
});
test('is redirects to nested secret using old non-engine url (a)', async function (assert) {
// Reported bug, backported fix https://github.com/hashicorp/vault/pull/24281
assert.expect(1);
const backend = this.backend;
await visit(`/vault/secrets/${backend}/list/app/`);
assert.strictEqual(currentURL(), `/vault/secrets/${backend}/kv/list/app/`);
});
test('versioned secret nav, tabs, breadcrumbs (a)', async function (assert) {
assert.expect(45);
const backend = this.backend;
Expand Down