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

reading kv secrets the proper way #187

Open
kbuchsicf opened this issue Oct 23, 2018 · 2 comments
Open

reading kv secrets the proper way #187

kbuchsicf opened this issue Oct 23, 2018 · 2 comments

Comments

@kbuchsicf
Copy link

I have secrets in Vault which I populated with the CLI: vault kv put -tls-skip-verify "secret/directory/$client" token="$clientToken"

When using vault-ruby to read these secrets back from Vault, I end up having to parse the Table format response:

kvarr = Vault.logical.read('secret/directory/sampleclient').data[:token].split("\n") clienttoken = kvarr.select { |line| /^token */.match(line) }[0].split(/ */)[1]

Is there a cleaner way to do this, or is this suggesting the need for the addition of a new API in vault-ruby, like: Vault.logical.kvget('secret/directory/sampleclient', 'token')

@mschuchard
Copy link

Vault.logical.read('secret/directory/sampleclient').data[:token] returns the value $clientToken in kv version 1 (which it looks like you are using based on the lack of the :data key). That additional parsing seems due to a multiline string.

@kbuchsicf
Copy link
Author

Thanks for helping me get back on track.

I was creating the clientToken via this vault command:
clientToken=$(vault token create -tls-skip-verify -display-name="${client}-level1" -orphan -policy="${client}-dir")

But, of course, that returns a table. So, I just needed to add "-field=token" to ensure I only get the token returned.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants