spring-cloud / spring-cloud-vault

Configuration Integration with HashiCorp Vault
http://cloud.spring.io/spring-cloud-vault/
Apache License 2.0
270 stars 151 forks source link

SpringBoot 3.0.2 + Spring Cloud 2022.0.1: Spring Cloud Vault will search secret/myapp secret/application/myprofile, etc... #671

Closed patpatpat123 closed 1 year ago

patpatpat123 commented 1 year ago

Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using. Version: SpringBoot 3.0.2 + Spring Cloud 2022.0.1 (But it is not version specific, observed with most of recent Spring Cloud Vault versions)

On application startup, Spring Cloud Vault will look into multiple paths of Vault, such as (only listing a few here) secret/myapp secret/application/myprofile secret/application

While I understand this can be a nice features for people storing secrets in multiple Vault paths, this is a little "useless" and actually, detrimental to Vault instance

First of all, if the secrets are only stored in one Vault path, and this is known in advanced, and not multiple paths, it does not make sense for Spring Cloud Vault to search in multiple places, where actually, there will be no other results (since the secrets are only stored in one unique Vault path)

Adding to that, this is detrimental to smaller Vault instances handling multiple instances from multiple different microservices. Not everyone has a giant very strong Vault instance. In our case, our Vault instance is quite small. But this small Vault instance is doing its job perfectly, protecting application secrets like a pro. It hold the secrets from application A, B, C, ... A has 3 instances, B has M instances, C has N instances.

Every time, on applications startup, each instance of each microservice will make a http call to Vault backend. Actually, only one from each is useful, with many duplicates to other paths yielding fore sure no secret.

Is it possible to just tell Vault: Hey, thanks but I am sure my secrets are only in this path /the/path. You do not need to make further http call to all the other paths, because nothing is there.

I hope to have been clear in the description of what seems to be an issue.

Thank you for your time considering it.

mp911de commented 1 year ago

This scheme comes from aligning with Spring Cloud Config Server to allow application- and environment-specific segmentation of configuration secrets. In the past, we've even extended this scheme as we've seen extensive usage of this approach.

You have three approaches if you need to customize Spring Cloud Vault behavior:

Let us know how this goes for you.

patpatpat123 commented 1 year ago

Hello @mp911de ,

We tried all three suggested possibilities and could see expected result. Many thanks