committed by
Spencer Gibb
parent
8fb43cf448
commit
a8f3d03593
@@ -1162,10 +1162,54 @@ spring:
|
||||
|
||||
----
|
||||
|
||||
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 <<custom-rest-template,provide a
|
||||
`RestTemplate`>> to the `ConfigServicePropertySourceLocator` (e.g. by
|
||||
grabbing it in the bootstrap context and injecting one).
|
||||
|
||||
[[custom-rest-template]]
|
||||
==== 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. Create a new configuration bean with an implementation of `PropertySourceLocator`.
|
||||
|
||||
.CustomConfigServiceBootstrapConfiguration.java
|
||||
[source,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;
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
3. In `resource/META_INF` create a file called
|
||||
`spring.factories` and specify your custom configuration.
|
||||
|
||||
.spring.factorties
|
||||
[source,properties]
|
||||
----
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user