-
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
Output full secret path in certain kv commands #14301
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.
Small nit comments, otherwise LGTM 👍
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.
This is a great addition that doesn't seem to muddy things up too much! Do you think there's an easy way to add some tests?
This is great! So, we decided against adding the Metadata path when returning the secret path due to difficulty? |
Yeah, I wasn't able to think of a way to get the metadata path at this point in the code, without breaking for paths that have words like "data" in the actual secret name or mount name. |
* Full secret path in table output of get and put * Add path output to KV patch and metadata get * Add changelog * Don't print secret path for kv-v1 * Make more readable * Switch around logic to not swallow error * Add test for secret path * Fix metadata test * Add unit test for padequalsigns * Remove wonky kv get tests
* Output full secret path in certain kv commands (#14301) * Full secret path in table output of get and put * Add path output to KV patch and metadata get * Add changelog * Don't print secret path for kv-v1 * Make more readable * Switch around logic to not swallow error * Add test for secret path * Fix metadata test * Add unit test for padequalsigns * Remove wonky kv get tests * Remove unneeded comments (#14423)
This PR is meant to mitigate some of the confusion for new Vault users, who often struggle with the discrepancy between the shortened path used by the CLI (
secret/foo
) and the real secret path (secret/data/foo
). This bites people when they've only worked with the CLI but then need to write a policy or make a logical call with our Go and Ruby client libraries.With this change,
vault kv get
,vault kv put
,vault kv patch
, andvault kv metadata get
will all output another top-level section when run intable
output mode. I did not add this to the kv commands that produce just a simple success message, and I did not add it to kv rollback as it seemed irrelevant given the use case.Examples:
Creating a new secret:
Reading a secret:
For
kv metadata get
, the same logic is used, but the header is slightly different:While "Data Path" may seem more internally accurate and matching with "Metadata Path", I chose to go with "Secret Path" for the main use case (regular kv commands) because I want totally new users who are not familiar with the /data /metadata subcategories to immediately intuit that this is the "real path" to their secret.