-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
There was a problem hiding this comment.
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.
Build Results: |
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 | ||
); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
// 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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.