Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

feat: support isBinary for Vault #449

Closed
wants to merge 1 commit into from
Closed

Conversation

ilkh
Copy link

@ilkh ilkh commented Jul 23, 2020

No description provided.

@@ -55,10 +57,16 @@ class VaultBackend extends KVBackend {
const secretResponse = await this._client.read(key)

if (kvVersion === 1) {
if (keyOptions && keyOptions.isBinary) {
secretResponse.data[property] = Buffer.from(secretResponse.data[property], 'base64').toString('utf8')
Copy link
Member

Choose a reason for hiding this comment

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

This feels kind of scary 😄 I guess its fine to turn it into a string but feels like we have an underlying problem in the code forcing us to write weird code :)
Main issue is probably that the KV backend expects us to return a string in _get forcing us to serialise here when we already have an object.

@pkrishnath
Copy link

pkrishnath commented Aug 5, 2020

Exactly what i am looking for .. Is there any way to store a base64 encoded value in vault and use external secrets to retrieve it ?

@@ -55,10 +57,16 @@ class VaultBackend extends KVBackend {
const secretResponse = await this._client.read(key)

if (kvVersion === 1) {
if (keyOptions && keyOptions.isBinary) {
secretResponse.data[property] = Buffer.from(secretResponse.data[property], 'base64').toString('utf8')
Copy link
Member

Choose a reason for hiding this comment

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

Would it be enough to not do the toString('utf8') here, just converting the base64 string to a buffer. later on this buffer will be base64 encoded again as the base class won't mess with buffers. This should put the original value from vault into the secret without it ending up double base64 encoded.

https://github.com/godaddy/kubernetes-external-secrets/blob/c3c27bc427c7129e4e98b5b10e4c5dde146c422d/lib/backends/kv-backend.js#L91-L93

https://github.com/godaddy/kubernetes-external-secrets/blob/c3c27bc427c7129e4e98b5b10e4c5dde146c422d/lib/backends/kv-backend.js#L130

Copy link
Member

@Flydiverny Flydiverny left a comment

Choose a reason for hiding this comment

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

Needs rebase and comments to be addressed. Should try returning a buffer from vault-backends get instead of a binary string.

@Flydiverny
Copy link
Member

Closing this in favor of #585

@Flydiverny Flydiverny closed this Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants