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

Handle show and edit views for old KV urls #24339

Merged
merged 23 commits into from Dec 8, 2023
Merged

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Dec 1, 2023

This PR builds off of the original LIST nested secret redirect PR.

If you navigate to an old kv v2 create, show, or edit url it will redirect you to the new kv engine url.

ex: http://localhost:4200/ui/vault/secrets/kv-test/create/test -> http://localhost:4200/ui/vault/secrets/kv-test/kv/create?initialKey=test

ex: http://localhost:4200/ui/vault/secrets/kv-test/create -> http://localhost:4200/ui/vault/secrets/kv-test/kv/create

ex: http://localhost:4200/ui/vault/secrets/kv-test/show/my-secret -> http://localhost:4200/ui/vault/secrets/kv-test/kv/my-secret/details?version=1

ex: http://localhost:4200/ui/vault/secrets/kv-test/edit/my-secret -> http://localhost:4200/ui/vault/secrets/kv-test/kv/complex/details?version=1

Note: I ran enterprise test locally and they passed.

@Monkeychip Monkeychip added the ui label Dec 1, 2023
@Monkeychip Monkeychip added this to the 1.15.4 milestone Dec 1, 2023
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Dec 1, 2023
@Monkeychip Monkeychip changed the title Handline show and edit views for old KV urls Handle show and edit views for old KV urls Dec 1, 2023
@Monkeychip Monkeychip marked this pull request as ready for review December 4, 2023 18:45
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still want to test the old 404 error page for all non kv v2 backend secrets routes, so I replaced with cubbyhole here.

Copy link

github-actions bot commented Dec 4, 2023

Build Results:
All builds succeeded! ✅

@Monkeychip Monkeychip added the backport/1.15.x Backport changes to `release/1.15.x` label Dec 4, 2023
Comment on lines 84 to 94
if (isAddonEngine(secretEngine.type, secretEngine.version)) {
// if no secret param redirect to the create route
// if secret param they are either viewing or editing secret so navigate to the details route
return !secret
? this.router.transitionTo('vault.cluster.secrets.backend.kv.create', secretEngine.id)
: this.router.transitionTo(
'vault.cluster.secrets.backend.kv.secret.details',
secretEngine.id,
secret
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious if there is a case where this route is accessed and the engine type is not kv since the isAddonEngine would return true for a few other different types. PKI came to mind but I think that's been converted to fully use the engine? It might be worth considering explicitly looking for secretEngine.type === 'kv' && secretEngine.version === 2 given the redirect routes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Thanks for thinking that one through 🙈 Amended.

ui/tests/acceptance/redirect-to-test.js Show resolved Hide resolved
// for kv v2, redirect users from the old url to the new engine url (1.15.0 +)
if (secretEngine.type === 'kv' && secretEngine.version === 2) {
// if no secret param redirect to the create route
// if secret param they are either viewing or editing secret so navigate to the details route
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't they just be editing since this is the secret-edit route?

Copy link
Contributor Author

@Monkeychip Monkeychip Dec 7, 2023

Choose a reason for hiding this comment

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

So I got this from the line here. And when I log mode from cubbyhole "Create" it hits this hook and the mode is "create-root". The routing is hard to follow so I literally just went with logging to figure if I needed to catch this path here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay - agreed, it is hard to follow!

@Monkeychip Monkeychip merged commit 77178c2 into main Dec 8, 2023
71 checks passed
@Monkeychip Monkeychip deleted the ui/VAULT-22392/kv-redirects branch December 8, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.15.x Backport changes to `release/1.15.x` hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants