diff --git a/spring-cloud-config.html b/spring-cloud-config.html index edb1d42d..1abd26d5 100644 --- a/spring-cloud-config.html +++ b/spring-cloud-config.html @@ -2238,11 +2238,67 @@ works locally and for a user-provided service on Cloud Foundry named
-

If you use another form of security you might need to provide a -RestTemplate to the ConfigServicePropertySourceLocator (e.g. by +

If you use another form of security you might need to provide a +RestTemplate to the ConfigServicePropertySourceLocator (e.g. by grabbing it in the bootstrap context and injecting one).

+

Providing A Custom RestTemplate

+
+

In some cases you might need to customize the requests made to the config server from +the client. Typically this involves passing special Authorization headers to +authenticate requests to the server. To provide a custom RestTemplate follow the +steps below.

+
+
+
    +
  1. +

    Set spring.cloud.config.enabled=false to disable the existing config server +property source.

    +
  2. +
  3. +

    Create a new configuration bean with an implementation of PropertySourceLocator.

    +
  4. +
+
+
+
CustomConfigServiceBootstrapConfiguration.java
+
+
@Configuration
+public class CustomConfigServiceBootstrapConfiguration {
+    @Bean
+    public ConfigClientProperties configClientProperties() {
+        ConfigClientProperties client = new ConfigClientProperties(this.environment);
+        client.setEnabled(false);
+        return client;
+    }
+
+    @Bean
+    public ConfigServicePropertySourceLocator configServicePropertySourceLocator() {
+        ConfigClientProperties clientProperties = configClientProperties();
+       ConfigServicePropertySourceLocator configServicePropertySourceLocator =  new ConfigServicePropertySourceLocator(clientProperties);
+        configServicePropertySourceLocator.setRestTemplate(customRestTemplate(clientProperties));
+        return configServicePropertySourceLocator;
+    }
+}
+
+
+
+
    +
  1. +

    In resource/META_INF create a file called +spring.factories and specify your custom configuration.

    +
  2. +
+
+
+
spring.factorties
+
+
org.springframework.cloud.bootstrap.BootstrapConfiguration = com.my.config.client.CustomConfigServiceBootstrapConfiguration
+
+
+
+

Vault

When using Vault as a backend to your config server the client will need to