FIX: Make vault kv module compatible with v2#54039
FIX: Make vault kv module compatible with v2#54039thenoid wants to merge 2 commits intosaltstack:developfrom
Conversation
This changes makes the vault module compatible with both version 1 and version 2 of the vault KV secret store This module uses the same method/calls that the vault client does to determine if the requested path is v1 or v2
|
Might it make sense to use |
Hehe, I actually just committed something similar to that in our testing environment, once I realized the helper functions would need to be available to also fix the SDB issue. I plan to push that up tomorrow after some testing. Throwing the WIP subject on there until I finish that up. |
This change moves the v2/metadata functions into the utils module. It also adds caching to the metadata lookup. Updates sdb/pillar to use the lookups.
|
Could we get some tests for this please? |
|
Okay, cache'ing is now working - here is example debug output fetching the same secret twice. |
@twangboy Not going to lie, the salt's python testing framework and I are not friends. I can munge other peoples tests well enough....but new ones are my kryptonite. |
| first: {{ supersecret.first }} | ||
| second: {{ supersecret.second }} | ||
| ''' | ||
| version2 = __utils__['vault.is_v2'](path) |
There was a problem hiding this comment.
you could have a get_info() that's doing the if, to avoid these 3 lines everywhere. That can return path & data (hence calling it get_info as opposed to get_path).
|
@thenoid there are some vault tests here: tests/integration/modules/test_vault.py Do those tests help give you direction on writing tests for this fix? If not anything else I can help answer or give direction with here? |
|
Hi, any change of getting this fix merged ? This is blocking us from using Vault kv with salt :-) |
|
@bluemalkin - things is, in the meanwhile, saltstack changed the branching strategy, and I'm afraid there are two things that are needed in order for this to get merged:
|
|
@thenoid @rares-pop sure - how can we please expedite this ? |
|
In all honesty, I'm super frustrated with saltstack's QA/Community/etc and not motivated to waste more time on this right now. If you want to write some tests i'll gladly update this PR with them. If not, just do what we've done with 21+ modules, copy my updated code to |
|
@bluemalkin , @thenoid - I'm not working at saltstack and I don't have push permissions here, so I can't help you directly. I'm contributing as you guys, and I'm doing reviews now and there, in an attempt to pay back the huge benefits that salt gave us. In fact I went ahead and posted a message on 'develop' channel to ask for someone from saltstack to review this and take any actions if that's wanted/possible. |
|
@thenoid Hey, thanks for the PR! Like @rares-pop said, we have changed the branching/release strategy, which can be frustrating - that's totally understandable. It's also entirely understandable if you're not super into contributing to Salt right now - life happens 🙂We absolutely understand that. We welcome and appreciate whatever level of contribution you're up for right now. To get the PR merged there are basically two options:
If you or anyone else is interested in rebasing, I've recorded a little screencast: https://asciinema.org/a/PWyeqbfV7ww5sT3AaX9yoIbF4 If you rebase, you'll need to edit this PR to point towards Are you at all interested in finishing this up, or would you like to let someone else take it over? |
Initial master-port of #54039 (support Vault kv version2)
What does this PR do?
Hashicorp vault introduced 'Key Value Store Version 2.0' which dramatically modified the path/structure of the KV secrets. However both are accessed using the same calls.
This changes makes the vault module compatible with both version 1 and version 2 of the vault KV secret store
This module uses the same method/calls that the vault client does to determine if the requested path is v1 or v2 (validated via vault audit logs).
Note: Some blog posts and the GitHub issue below suggest adding extra
dataormetadatato your path manually. Which "worked" but was super not user friendly and could lead to interesting results if you needed both the data and metadata.What issues does this PR fix or reference?
Some of the "modify the path" suggestions where here....though looks like I need to port the v2 logic over to the sub module as well. #50186
Previous Behavior
When attempting to access a KV2 secret, you would receive a 403 because the path was incorrect.
New Behavior
You can actually read v2 secrets!
Tests written?
No
Commits signed with GPG?
No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.