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

Add support for Key/Value backend version 2 (versioning enabled) #209

Closed
mp911de opened this issue Apr 18, 2018 · 7 comments
Closed

Add support for Key/Value backend version 2 (versioning enabled) #209

mp911de opened this issue Apr 18, 2018 · 7 comments

Comments

@mp911de
Copy link
Member

mp911de commented Apr 18, 2018

Spring Cloud Vault is not usable with Vault's versioned Key/Value backend introduced with 0.10.0. The versioned backend is enabled by default which adds another level of severity.

The versioned Key/Value backend entirely changed its API (nested responses, e.g. {data: { data: { here comes the actual payload }}, changed API paths e.g. secret/data/secret-name instead of secret/secret-name). It is possible to read from …/data/… paths but referencing secrets requires a ${data.…} prefix to unwrap nesting.

Using the Key/Value backend allows a uniform API even if versioning is disabled by setting an HTTP header (X-Vault-Kv-Client: v2) but the client has to be aware it's reading from a key-value backend.

Using a newer format (paths, unwrapping) breaks compatibility with older Vault versions and isn't really a good option.

mp911de added a commit that referenced this issue Apr 24, 2018
We now provide configuration support for the versioned key-value backend introduced with Vault 0.10.0. This backend uses configuration properties prefixed with spring.cloud.vault.kv and defaults to the secret mount path. It resembles configuration properties from the generic secret backend. Using the versioned key-value backend requires disabling the generic secret backend (spring.cloud.vault.generic.enabled=false).

The versioned key-value backend can be configured programmatically through SecretBackendConfigurer.add(KeyValueSecretBackendMetadata.create(…)) which will add data path segments and unwrap nested data elements from the response.

See gh-209.
@mp911de
Copy link
Member Author

mp911de commented Apr 24, 2018

Vault folks have removed request downgrading (by using the X-Vault-Kv-Client: v2 header, see hashicorp/vault-plugin-secrets-kv#11) in Vault 0.10.1 so we can't come up with a uniform API as the client has no knowledge of the underlying backend for a particular path. We provide now a new backend/configuration type (spring.cloud.vault.kv) resembling generic secret backend configuration properties allowing reading from the versioned key-value backend along with element unwrapping.

However, clients have to be aware they are reading from the versioned key-value backend.

@tonny1983
Copy link

I just faced the same problem that the current spring-cloud-vault can only obtain data via vault's K/V version 1, but it seems the default K/V version is 2 from vault 0.10.0, and there're some config tasks to change the K/V version to 1. Thus, may I know to which version/milestone will the new feature of spring-cloud-vault be released? Thanks a lot.

@mp911de
Copy link
Member Author

mp911de commented Apr 27, 2018

Spring Cloud Vault support for the versioned backend will come with Spring Cloud Vault 2.0 GA (see https://github.com/spring-cloud/spring-cloud-release/milestones for dates).

A general notice: Vault versions are still 0.x so we should anticipate future (non-backward compatible) changes. The upcoming 0.10.1 release comes with breaking changes in terms of interop between versioned and non-versioned key-value backends.

@mikeblum
Copy link

I have a stop-gap solution for now that creates the legacy V1 store and confiugres spring-cloud-vault to use that backend:

Create a version 1 (non-versioend) keystore:
vault secrets enable -version=1 -path=v1 -description="v1 secrets store" kv

bootstrap.properties

spring.cloud.vault.generic.enabled=true
spring.cloud.vault.generic.backend=v1

For easy migration to the v2 store I've created another v2 store:

Create a version 2 (default secret and versioned) keystore:
vault secrets enable -version=2 -path=v2 -description="v2 versioned secrets store" kv

@mp911de
Copy link
Member Author

mp911de commented Jun 12, 2018

Request downgrading has been removed. We introduced with the spring.cloud.vault.kv property namespace that default to Key-Value API version 2 usage. spring.cloud.vault.generic uses Key-Value API version 1.

@mp911de mp911de closed this as completed Jun 12, 2018
@mp911de mp911de added this to the 2.0.0 milestone Jun 12, 2018
@mp911de mp911de changed the title Key/Value backend not usable with Vault 0.10.0 (versioning enabled) Add support for Key/Value backend version 2 (versioning enabled) Jun 12, 2018
@moreirajo
Copy link

I see that this is now supported in VaultTemplate, what about ReactiveVaultTemplate?

@cantaylancapraz
Copy link

cantaylancapraz commented Jun 2, 2022

As I see, reactiveVaultTemplate is not supported. I think this issue should be reopened

spencergibb pushed a commit that referenced this issue Sep 14, 2023
We now provide configuration support for the versioned key-value backend introduced with Vault 0.10.0. This backend uses configuration properties prefixed with spring.cloud.vault.kv and defaults to the secret mount path. It resembles configuration properties from the generic secret backend. Using the versioned key-value backend requires disabling the generic secret backend (spring.cloud.vault.generic.enabled=false).

The versioned key-value backend can be configured programmatically through SecretBackendConfigurer.add(KeyValueSecretBackendMetadata.create(…)) which will add data path segments and unwrap nested data elements from the response.

See gh-209.
spencergibb pushed a commit that referenced this issue Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants