Class VaultAutoConfiguration

java.lang.Object
org.springframework.cloud.vault.config.VaultAutoConfiguration
Direct Known Subclasses:
VaultBootstrapConfiguration

@Configuration(proxyBeanMethods=false) @ConditionalOnProperty(name="spring.cloud.vault.enabled", matchIfMissing=true) @EnableConfigurationProperties(VaultProperties.class) @Order(2147483642) public class VaultAutoConfiguration extends Object
Auto-configuration for Spring Vault support.
Since:
3.0
Author:
Spencer Gibb, Mark Paluch
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Wrapper to keep TaskScheduler local to Spring Cloud Vault.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VaultAutoConfiguration(org.springframework.context.ConfigurableApplicationContext applicationContext, VaultProperties vaultProperties, org.springframework.beans.factory.ObjectProvider<org.springframework.vault.client.VaultEndpointProvider> endpointProvider, org.springframework.beans.factory.ObjectProvider<List<org.springframework.vault.client.RestTemplateCustomizer>> customizers, org.springframework.beans.factory.ObjectProvider<List<org.springframework.vault.client.RestTemplateRequestCustomizer<?>>> requestCustomizers)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.vault.authentication.ClientAuthentication
    clientAuthentication(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper, org.springframework.vault.client.RestTemplateFactory restTemplateFactory)
     
    org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper
    Creates a AbstractVaultConfiguration.ClientFactoryWrapper containing a ClientHttpRequestFactory.
    protected org.springframework.vault.client.RestTemplateBuilder
    restTemplateBuilder(org.springframework.http.client.ClientHttpRequestFactory requestFactory)
    Create a RestTemplateBuilder initialized with VaultEndpointProvider and ClientHttpRequestFactory.
    org.springframework.vault.client.RestTemplateFactory
    vaultRestTemplateFactory(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper)
    Create a RestTemplateFactory bean that is used to produce RestTemplate.
    org.springframework.vault.authentication.SessionManager
    vaultSessionManager(org.springframework.vault.authentication.ClientAuthentication clientAuthentication, org.springframework.beans.factory.ObjectFactory<VaultAutoConfiguration.TaskSchedulerWrapper> asyncTaskExecutorFactory, org.springframework.vault.client.RestTemplateFactory restTemplateFactory)
     
    Creates a new VaultAutoConfiguration.TaskSchedulerWrapper that encapsulates a bean implementing TaskScheduler and AsyncTaskExecutor.
    org.springframework.vault.core.VaultTemplate
    vaultTemplate(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper)
    Creates a VaultTemplate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VaultAutoConfiguration

      public VaultAutoConfiguration(org.springframework.context.ConfigurableApplicationContext applicationContext, VaultProperties vaultProperties, org.springframework.beans.factory.ObjectProvider<org.springframework.vault.client.VaultEndpointProvider> endpointProvider, org.springframework.beans.factory.ObjectProvider<List<org.springframework.vault.client.RestTemplateCustomizer>> customizers, org.springframework.beans.factory.ObjectProvider<List<org.springframework.vault.client.RestTemplateRequestCustomizer<?>>> requestCustomizers)
  • Method Details

    • restTemplateBuilder

      protected org.springframework.vault.client.RestTemplateBuilder restTemplateBuilder(org.springframework.http.client.ClientHttpRequestFactory requestFactory)
      Create a RestTemplateBuilder initialized with VaultEndpointProvider and ClientHttpRequestFactory. May be overridden by subclasses.
      Parameters:
      requestFactory - the ClientHttpRequestFactory.
      Returns:
      the RestTemplateBuilder.
      Since:
      2.3
      See Also:
    • clientHttpRequestFactoryWrapper

      @Bean @ConditionalOnMissingBean public org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientHttpRequestFactoryWrapper()
      Creates a AbstractVaultConfiguration.ClientFactoryWrapper containing a ClientHttpRequestFactory. ClientHttpRequestFactory is not exposed as root bean because ClientHttpRequestFactory is configured with ClientOptions and SslConfiguration which are not necessarily applicable for the whole application.
      Returns:
      the AbstractVaultConfiguration.ClientFactoryWrapper to wrap a ClientHttpRequestFactory instance.
    • vaultRestTemplateFactory

      @Bean @ConditionalOnMissingBean public org.springframework.vault.client.RestTemplateFactory vaultRestTemplateFactory(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper)
      Create a RestTemplateFactory bean that is used to produce RestTemplate.
      Parameters:
      clientFactoryWrapper - the AbstractVaultConfiguration.ClientFactoryWrapper.
      Returns:
      the RestTemplateFactory.
      Since:
      3.0
      See Also:
    • vaultTemplate

      @Bean @ConditionalOnMissingBean(org.springframework.vault.core.VaultOperations.class) public org.springframework.vault.core.VaultTemplate vaultTemplate(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper)
      Creates a VaultTemplate.
      Parameters:
      clientFactoryWrapper - the AbstractVaultConfiguration.ClientFactoryWrapper.
      Returns:
      the VaultTemplate bean.
      See Also:
    • vaultTaskScheduler

      @Bean @Lazy @ConditionalOnMissingBean(TaskSchedulerWrapper.class) public VaultAutoConfiguration.TaskSchedulerWrapper vaultTaskScheduler()
      Creates a new VaultAutoConfiguration.TaskSchedulerWrapper that encapsulates a bean implementing TaskScheduler and AsyncTaskExecutor.
      Returns:
      the VaultAutoConfiguration.TaskSchedulerWrapper bean.
      See Also:
      • ThreadPoolTaskScheduler
    • vaultSessionManager

      @Bean @ConditionalOnMissingBean @ConditionalOnAuthentication public org.springframework.vault.authentication.SessionManager vaultSessionManager(org.springframework.vault.authentication.ClientAuthentication clientAuthentication, org.springframework.beans.factory.ObjectFactory<VaultAutoConfiguration.TaskSchedulerWrapper> asyncTaskExecutorFactory, org.springframework.vault.client.RestTemplateFactory restTemplateFactory)
      Parameters:
      clientAuthentication - the ClientAuthentication.
      asyncTaskExecutorFactory - the ObjectFactory for VaultAutoConfiguration.TaskSchedulerWrapper.
      restTemplateFactory - the RestTemplateFactory.
      Returns:
      the SessionManager for Vault session management.
      See Also:
      • SessionManager
      • LifecycleAwareSessionManager
    • clientAuthentication

      @Bean @ConditionalOnMissingBean @ConditionalOnAuthentication public org.springframework.vault.authentication.ClientAuthentication clientAuthentication(org.springframework.vault.config.AbstractVaultConfiguration.ClientFactoryWrapper clientFactoryWrapper, org.springframework.vault.client.RestTemplateFactory restTemplateFactory)
      Parameters:
      clientFactoryWrapper - the AbstractVaultConfiguration.ClientFactoryWrapper.
      restTemplateFactory - the RestTemplateFactory.
      Returns:
      the ClientAuthentication to obtain a VaultToken.
      See Also:
      • SessionManager
      • LifecycleAwareSessionManager