spring-cloud / spring-cloud-vault

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

Add support for propertyNamePrefix on bootstrap.properties/yaml #521

Closed douglasmsouza closed 2 years ago

douglasmsouza commented 3 years ago

Is your feature request related to a problem? Please describe.

I often have to load multiple secrets from vault which can contain repeated property names (e.g. host property). To distinguish one property from another, I usually create a configuration bean with @VaultPropertySource and propertyNamePrefix.

It would be great if i could make this configuration on bootstrap.properties, inside spring.cloud.vault section, like I can do on Quarkus.

Describe the solution you'd like

Here is an example of my current solution:

@Configuration
@VaultPropertySource(value = "secrets/db", propertyNamePrefix = "db.")
@VaultPropertySource(value = "secrets/mail", propertyNamePrefix = "mail.")
public class VaultSecrets {
}

Here is an example of desired solution, based on Quarkus configuration:

quarkus:
  vault:
    url: ${vault_url}
    kv-secret-engine-mount-path: secrets
    kv-secret-engine-version: 2
    authentication:
      app-role:
        role-id: ${vault_role_id}
        secret-id: ${vault_secret_id}
    # Here is the prefix configuration. I can load secrets/db and secrets/mail configuring the prefix like secret-config-kv-path.{prefix}
    secret-config-kv-path:
      db: secrets/db
      mail: secrets/mail

where the propertyNamePrefix is any property inside secret-config-kv-path

mp911de commented 3 years ago

That feature is available through org.springframework.cloud.vault.config.VaultConfigurer as workaround. We might consider extending the way how to declare mounts, also in combination with #459.

mp911de commented 2 years ago

See #488 which introduced a prefix for individual Vault locations that is prepended to property names when using the Config Data API. We do not plan on extending bootstrap support as the Bootstrap Context is deprecated.