Class VaultConfigDataLocationResolver

java.lang.Object
org.springframework.cloud.vault.config.VaultConfigDataLocationResolver
All Implemented Interfaces:
org.springframework.boot.context.config.ConfigDataLocationResolver<VaultConfigLocation>

public class VaultConfigDataLocationResolver extends Object implements org.springframework.boot.context.config.ConfigDataLocationResolver<VaultConfigLocation>
ConfigDataLocationResolver for Vault resolving VaultConfigLocation using the vault: prefix.

Resolution considers contextual locations as we as default locations. Contextual locations such as vault:secret/my-application are considered to be context paths for the Key-Value secrets backend. Using a default location vault: imports all enabled secret backends by creating SecretBackendMetadata from SecretBackendMetadataFactory. Note that both types,VaultSecretBackendDescriptor and SecretBackendMetadataFactory are resolved through spring.factories to allow optional presence/absence on the class path.

Mixing paths (spring.config.import=vault:,vault:secret/my-application,vault:secret/other-location) is possible as each config location creates an individual VaultConfigLocation. By enabling/disabling a VaultSecretBackendDescriptor, you can control the amount of secret backends that are imported through the default location.

You can customize the default location capabilities by registering VaultConfigurer in the BootstrapRegistry. For example:

VaultConfigurer configurer = …;
SpringApplication application = …;

application.addBootstrapper(registy -> register(VaultConfigurer.class, context -> configurer));

Registers also VaultProperties in the BootstrapRegistry that is required later on by VaultConfigDataLoader.

Since:
3.0
Author:
Mark Paluch, Jeffrey van der Laan
See Also:
  • Constructor Details

    • VaultConfigDataLocationResolver

      public VaultConfigDataLocationResolver()
  • Method Details

    • isResolvable

      public boolean isResolvable(org.springframework.boot.context.config.ConfigDataLocationResolverContext context, org.springframework.boot.context.config.ConfigDataLocation location)
      Specified by:
      isResolvable in interface org.springframework.boot.context.config.ConfigDataLocationResolver<VaultConfigLocation>
    • resolve

      public List<VaultConfigLocation> resolve(org.springframework.boot.context.config.ConfigDataLocationResolverContext context, org.springframework.boot.context.config.ConfigDataLocation location) throws org.springframework.boot.context.config.ConfigDataLocationNotFoundException, org.springframework.boot.context.config.ConfigDataResourceNotFoundException
      Specified by:
      resolve in interface org.springframework.boot.context.config.ConfigDataLocationResolver<VaultConfigLocation>
      Throws:
      org.springframework.boot.context.config.ConfigDataLocationNotFoundException
      org.springframework.boot.context.config.ConfigDataResourceNotFoundException
    • resolveProfileSpecific

      public List<VaultConfigLocation> resolveProfileSpecific(org.springframework.boot.context.config.ConfigDataLocationResolverContext context, org.springframework.boot.context.config.ConfigDataLocation location, org.springframework.boot.context.config.Profiles profiles) throws org.springframework.boot.context.config.ConfigDataLocationNotFoundException
      Specified by:
      resolveProfileSpecific in interface org.springframework.boot.context.config.ConfigDataLocationResolver<VaultConfigLocation>
      Throws:
      org.springframework.boot.context.config.ConfigDataLocationNotFoundException