diff --git a/multi/multi__embedding_the_config_server.html b/multi/multi__embedding_the_config_server.html index b520a7ed..39187b6a 100644 --- a/multi/multi__embedding_the_config_server.html +++ b/multi/multi__embedding_the_config_server.html @@ -1,6 +1,6 @@
-The Config Server runs best as a standalone application. +
The Config Server runs best as a standalone application.
However, if need be, you can embed it in another application.
To do so, use the @EnableConfigServer annotation.
An optional property named spring.cloud.config.server.bootstrap can be useful in this case is.
diff --git a/multi/multi__push_notifications_and_spring_cloud_bus.html b/multi/multi__push_notifications_and_spring_cloud_bus.html
index 2e4df787..108bcafd 100644
--- a/multi/multi__push_notifications_and_spring_cloud_bus.html
+++ b/multi/multi__push_notifications_and_spring_cloud_bus.html
@@ -1,6 +1,6 @@
Many source code repository providers (such as Github, Gitlab, Gitea, Gitee, Gogs, or Bitbucket) notify you of changes in a repository through a webhook. +
Many source code repository providers (such as Github, Gitlab, Gitea, Gitee, Gogs, or Bitbucket) notify you of changes in a repository through a webhook.
You can configure the webhook through the provider’s user interface as a URL and a set of events in which you are interested.
For instance, Github uses a POST to the webhook with a JSON body containing a list of commits and a header (X-Github-Event) set to push.
If you add a dependency on the spring-cloud-config-monitor library and activate the Spring Cloud Bus in your Config Server, then a /monitor endpoint is enabled.
When the webhook is activated, the Config Server sends a RefreshRemoteApplicationEvent targeted at the applications it thinks might have changed.
diff --git a/multi/multi__quick_start.html b/multi/multi__quick_start.html
index d04a722d..87429e57 100644
--- a/multi/multi__quick_start.html
+++ b/multi/multi__quick_start.html
@@ -1,6 +1,6 @@
This quick start walks through using both the server and the client of Spring Cloud Config Server.
First, start the server, as follows:
$ cd spring-cloud-config-server +1. Quick Start This quick start walks through using both the server and the client of Spring Cloud Config Server.
First, start the server, as follows:
$ cd spring-cloud-config-server $ ../mvnw spring-boot:runThe server is a Spring Boot application, so you can run it from your IDE if you prefer to do so (the main class is
ConfigServerApplication).Next try out a client, as follows:
$ curl localhost:8888/foo/development {"name":"foo","label":"master","propertySources":[ {"name":"https://github.com/scratches/config-repo/foo-development.properties","source":{"bar":"spam"}}, diff --git a/multi/multi__serving_alternative_formats.html b/multi/multi__serving_alternative_formats.html index 1a0c399d..87c3556c 100644 --- a/multi/multi__serving_alternative_formats.html +++ b/multi/multi__serving_alternative_formats.html @@ -1,6 +1,6 @@ -3. Serving Alternative Formats The default JSON format from the environment endpoints is perfect for consumption by Spring applications, because it maps directly onto the
Environmentabstraction. +3. Serving Alternative Formats The default JSON format from the environment endpoints is perfect for consumption by Spring applications, because it maps directly onto the
Environmentabstraction. If you prefer, you can consume the same data as YAML or Java properties by adding a suffix (".yml", ".yaml" or ".properties") to the resource path. This can be useful for consumption by applications that do not care about the structure of the JSON endpoints or the extra metadata they provide (for example, an application that is not using Spring might benefit from the simplicity of this approach).The YAML and properties representations have an additional flag (provided as a boolean query parameter called
resolvePlaceholders) to signal that placeholders in the source documents (in the standard Spring${…}form) should be resolved in the output before rendering, where possible. This is a useful feature for consumers that do not know about the Spring placeholder conventions.
Note There are limitations in using the YAML or properties formats, mainly in relation to the loss of metadata. diff --git a/multi/multi__serving_plain_text.html b/multi/multi__serving_plain_text.html index 7892d605..2d3fa600 100644 --- a/multi/multi__serving_plain_text.html +++ b/multi/multi__serving_plain_text.html @@ -1,6 +1,6 @@
-4. Serving Plain Text Instead of using the
Environmentabstraction (or one of the alternative representations of it in YAML or properties format), your applications might need generic plain-text configuration files that are tailored to their environment. +4. Serving Plain Text Instead of using the
-Environmentabstraction (or one of the alternative representations of it in YAML or properties format), your applications might need generic plain-text configuration files that are tailored to their environment. The Config Server provides these through an additional endpoint at/{name}/{profile}/{label}/{path}, wherename,profile, andlabelhave the same meaning as the regular environment endpoint, butpathis a file name (such aslog.xml). The source files for this endpoint are located in the same way as for the environment endpoints. The same search path is used for properties and YAML files. diff --git a/multi/multi__spring_cloud_config_client.html b/multi/multi__spring_cloud_config_client.html index 3fbccbe3..3ac2ffad 100644 --- a/multi/multi__spring_cloud_config_client.html +++ b/multi/multi__spring_cloud_config_client.html @@ -1,9 +1,9 @@7. Spring Cloud Config Client A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources provided by the application developer). +
7. Spring Cloud Config Client A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources provided by the application developer). It also picks up some additional useful features related to
Environmentchange events.The default behavior for any application that has the Spring Cloud Config Client on the classpath is as follows: When a config client starts, it binds to the Config Server (through the
spring.cloud.config.uribootstrap configuration property) and initializes SpringEnvironmentwith remote property sources.The net result of this behavior is that all client applciations that want to consume the Config Server need a
bootstrap.yml(or an environment variable) with the server address set inspring.cloud.config.uri(it defaults to "http://localhost:8888").If you use a `DiscoveryClient implementation, such as Spring Cloud Netflix and Eureka Service Discovery or Spring Cloud Consul, you can have the Config Server register with the Discovery Service. -However, in the default “Config First” mode, clients cannot take advantage of the registration.
If you prefer to use
DiscoveryClientto locate the Config Server, you can do so by settingspring.cloud.config.discovery.enabled=true(the default isfalse). +However, in the default “Config First” mode, clients cannot take advantage of the registration.If you prefer to use
-DiscoveryClientto locate the Config Server, you can do so by settingspring.cloud.config.discovery.enabled=true(the default isfalse). The net result of doing so is that client applications all need abootstrap.yml(or an environment variable) with the appropriate discovery configuration. For example, with Spring Cloud Netflix, you need to define the Eureka server address (for example, ineureka.client.serviceUrl.defaultZone). The price for using this option is an extra network round trip on startup, to locate the service registration. diff --git a/multi/multi__spring_cloud_config_server.html b/multi/multi__spring_cloud_config_server.html index e9b15ce7..ce7a9bd8 100644 --- a/multi/multi__spring_cloud_config_server.html +++ b/multi/multi__spring_cloud_config_server.html @@ -1,6 +1,6 @@2. Spring Cloud Config Server Spring Cloud Config Server provides an HTTP resource-based API for external configuration (name-value pairs or equivalent YAML content). +
2. Spring Cloud Config Server Spring Cloud Config Server provides an HTTP resource-based API for external configuration (name-value pairs or equivalent YAML content). The server is embeddable in a Spring Boot application, by using the
@EnableConfigServerannotation. Consequently, the following application is a config server:ConfigServer.java.
@SpringBootApplication @@ -60,12 +60,12 @@ If you use a command-line client such as curl, be careful with the brackets in t git: uri: https://example.com/my/repo timeout: 4Spring Cloud Config Server supports a git repository URL with placeholders for the
{application}and{profile}(and{label}if you need it, but remember that the label is applied as a git label anyway). -So you can support a “one repository per application” policy by using a structure similar to the following:spring: +So you can support a “one repository per application” policy by using a structure similar to the following:spring: cloud: config: server: git: - uri: https://github.com/myorg/{application}You can also support a “one repository per profile” policy by using a similar pattern but with + uri: https://github.com/myorg/{application}
You can also support a “one repository per profile” policy by using a similar pattern but with
{profile}.Additionally, using the special string "(_)" within your
{application}parameters can enable support for multiple organizations, as shown in the following example:spring: cloud: @@ -88,7 +88,7 @@ The pattern format is a comma-separated list of{applicati local: pattern: local* uri: file:/home/configsvc/config-repoIf
{application}/{profile}does not match any of the patterns, it uses the default URI defined underspring.cloud.config.server.git.uri. -In the above example, for the “simple” repository, the pattern issimple/*(it only matches one application namedsimplein all profiles). The “local” repository matches all application names beginning withlocalin all profiles (the/*suffix is added automatically to any pattern that does not have a profile matcher).
Note The “one-liner” short cut used in the “simple” example can be used only if the only property to be set is the URI. +In the above example, for the “simple” repository, the pattern is
simple/*(it only matches one application namedsimplein all profiles). The “local” repository matches all application names beginning withlocalin all profiles (the/*suffix is added automatically to any pattern that does not have a profile matcher).
Note The “one-liner” short cut used in the “simple” example can be used only if the only property to be set is the URI. If you need to set anything else (credentials, pattern, and so on) you need to use the full form.
The
patternproperty in the repo is actually an array, so you can use a YAML array (or[0],[1], etc. suffixes in properties files) to bind to multiple patterns. You may need to do so if you are going to run apps with multiple profiles, as shown in the following example:spring: cloud: @@ -107,7 +107,7 @@ You may need to do so if you are going to run apps with multiple profiles, as sh - '*/qa' - '*/production' uri: https://github.com/staging/config-repo
Note Spring Cloud guesses that a pattern containing a profile that does not end in
*implies that you actually want to match a list of profiles starting with this pattern (so*/stagingis a shortcut for["*/staging", "*/staging,*"], and so on). -This is common where, for instance, you need to run applications in the “development” profile locally but also the “cloud” profile remotely.Every repository can also optionally store config files in sub-directories, and patterns to search for those directories can be specified as
searchPaths. +This is common where, for instance, you need to run applications in the “development” profile locally but also the “cloud” profile remotely.Every repository can also optionally store config files in sub-directories, and patterns to search for those directories can be specified as
searchPaths. The following example shows a config file at the top level:spring: cloud: config: @@ -195,7 +195,7 @@ In order to activate property-based SSH configuration, the69pcVH/4rmLbXdcmNYGm6iu+MlPQk4BUZknHSmVHIFdJ0EPupVaQ8RHT - -----END RSA PRIVATE KEY-----The following table describes the SSH configuration properties.
Table 2.1. SSH Configuration Properties
Property Name Remarks ignoreLocalSshSettings
If
true, use property-based instead of file-based SSH config. Must be set at asspring.cloud.config.server.git.ignoreLocalSshSettings, not inside a repository definition.privateKey
Valid SSH private key. Must be set if
ignoreLocalSshSettingsis true and Git URI is SSH format.hostKey
Valid SSH host key. Must be set if
hostKeyAlgorithmis also set.hostKeyAlgorithm
One of
ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, or ecdsa-sha2-nistp521. Must be set ifhostKeyis also set.strictHostKeyChecking
trueorfalse. If false, ignore errors with host key.knownHostsFile
Location of custom
.known_hostsfile.preferredAuthentications
Override server authentication method order. This should allow for evading login prompts if server has keyboard-interactive authentication before the
publickeymethod.Spring Cloud Config Server also supports a search path with placeholders for the
{application}and{profile}(and{label}if + -----END RSA PRIVATE KEY-----The following table describes the SSH configuration properties.
Table 2.1. SSH Configuration Properties
Property Name Remarks ignoreLocalSshSettings
If
true, use property-based instead of file-based SSH config. Must be set at asspring.cloud.config.server.git.ignoreLocalSshSettings, not inside a repository definition.privateKey
Valid SSH private key. Must be set if
ignoreLocalSshSettingsis true and Git URI is SSH format.hostKey
Valid SSH host key. Must be set if
hostKeyAlgorithmis also set.hostKeyAlgorithm
One of
ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, or ecdsa-sha2-nistp521. Must be set ifhostKeyis also set.strictHostKeyChecking
trueorfalse. If false, ignore errors with host key.knownHostsFile
Location of custom
.known_hostsfile.preferredAuthentications
Override server authentication method order. This should allow for evading login prompts if server has keyboard-interactive authentication before the
publickeymethod.Spring Cloud Config Server also supports a search path with placeholders for the
{application}and{profile}(and{label}if you need it), as shown in the following example:spring: cloud: config: @@ -246,7 +246,7 @@ By default, they are put in the system temporary directory with a prefix of/tmp/config-repo-<randomid>. Some operating systems routinely clean out temporary directories. This can lead to unexpected behavior, such as missing properties. -To avoid this problem, change the directory that Config Server uses by setting spring.cloud.config.server.git.basedirorspring.cloud.config.server.svn.basedirto a directory that does not reside in the system temp structure.There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with
spring.cloud.config.server.native.searchLocations). +To avoid this problem, change the directory that Config Server uses by settingspring.cloud.config.server.git.basedirorspring.cloud.config.server.svn.basedirto a directory that does not reside in the system temp structure.There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with
spring.cloud.config.server.native.searchLocations). To use the native profile, launch the Config Server withspring.profiles.active=native.
Note Remember to use the
file:prefix for file resources (the default without a prefix is usually the classpath). As with any Spring Boot configuration, you can embed${}-style environment placeholders, but remember that absolute paths in Windows require an extra/(for example,file:///${user.home}/config-repo).
Warning The default value of the
searchLocationsis identical to a local Spring Boot application (that is,[classpath:/, classpath:/config, file:./, file:./config]). @@ -255,12 +255,12 @@ To use it in production, you need to be sure that the file system is reliable an In this way, you can segregate the directories in the path and choose a strategy that makes sense for you (such as subdirectory per application or subdirectory per profile).If you do not use placeholders in the search locations, this repository also appends the
{label}parameter of the HTTP resource to a suffix on the search path, so properties files are loaded from each search location and a subdirectory with the same name as the label (the labelled properties take precedence in the Spring Environment). Thus, the default behaviour with no placeholders is the same as adding a search location ending with/{label}/. For example,file:/tmp/configis the same asfile:/tmp/config,file:/tmp/config/{label}. -This behavior can be disabled by settingspring.cloud.config.server.native.addLabelLocations=false.Spring Cloud Config Server also supports Vault as a backend.
Spring Cloud Config Server also supports Vault as a backend.
For more information on Vault, see the Vault quick start guide.
To enable the config server to use a Vault backend, you can run your config server with the
vaultprofile. For example, in your config server’sapplication.properties, you can addspring.profiles.active=vault.By default, the config server assumes that your Vault server runs at
http://127.0.0.1:8200. It also assumes that the name of backend issecretand the key isapplication. All of these defaults can be configured in your config server’sapplication.properties. -The following table describes configurable Vault properties:
Name Default Value host
127.0.0.1
port
8200
scheme
http
backend
secret
defaultKey
application
profileSeparator
,
kvVersion
1
skipSslValidation
false
timeout
5
Important All of the properties in the preceding table must be prefixed with
spring.cloud.config.server.vault.All configurable properties can be found in
org.springframework.cloud.config.server.environment.VaultEnvironmentRepository.Vault 0.10.0 introduced a versioned key-value backend (k/v backend version 2) that exposes a different API than earlier versions, it now requires a
data/between the mount path and the actual context path and wraps secrets in adataobject. SettingkvVersion=2will take this into account.With your config server running, you can make HTTP requests to the server to retrieve +The following table describes configurable Vault properties:
Name Default Value host
127.0.0.1
port
8200
scheme
http
backend
secret
defaultKey
application
profileSeparator
,
kvVersion
1
skipSslValidation
false
timeout
5
Important All of the properties in the preceding table must be prefixed with
spring.cloud.config.server.vault.All configurable properties can be found in
org.springframework.cloud.config.server.environment.VaultEnvironmentRepository.Vault 0.10.0 introduced a versioned key-value backend (k/v backend version 2) that exposes a different API than earlier versions, it now requires a
data/between the mount path and the actual context path and wraps secrets in adataobject. SettingkvVersion=2will take this into account.With your config server running, you can make HTTP requests to the server to retrieve values from the Vault backend. To do so, you need a token for your Vault server.
First, place some data in you Vault, as shown in the following example:
$ vault write secret/application foo=bar baz=bam $ vault write secret/myapp foo=myappsbarSecond, make an HTTP request to your config server to retrieve the values, as shown in the following example:
$ curl -X "GET" "http://localhost:8888/myapp/default" -H "X-Config-Token: yourtoken"You should see a response similar to the following:
{ @@ -292,7 +292,7 @@ secret/myApp secret/application,dev secret/applicationProperties written to
secret/applicationare available to all applications using the Config Server. An application with the name,myApp, would have any properties written tosecret/myAppandsecret/applicationavailable to it. -WhenmyApphas thedevprofile enabled, properties written to all of the above paths would be available to it, with properties in the first path in the list taking priority over the others.The configuration server can access a Git or Vault backend through an HTTP or HTTPS proxy. This behavior is controlled for either Git or Vault by settings under
proxy.httpandproxy.https. These settings are per repository, so if you are using a composite environment repository you must configure proxy settings for each backend in the composite individually. If using a network which requires separate proxy servers for HTTP and HTTPS URLs, you can configure both the HTTP and the HTTPS proxy settings for a single backend.The following table describes the proxy configuration properties for both HTTP and HTTPS proxies. All of these properties must be prefixed by
proxy.httporproxy.https.Table 2.2. Proxy Configuration Properties
Property Name Remarks host
The host of the proxy.
port
The port with which to access the proxy.
nonProxyHosts
Any hosts which the configuration server should access outside the proxy. If values are provided for both
proxy.http.nonProxyHostsandproxy.https.nonProxyHosts, theproxy.httpvalue will be used.username
The username with which to authenticate to the proxy. If values are provided for both
proxy.http.usernameandproxy.https.username, theproxy.httpvalue will be used.password
The password with which to authenticate to the proxy. If values are provided for both
proxy.http.passwordandproxy.https.password, theproxy.httpvalue will be used.The following configuration uses an HTTPS proxy to access a Git repository.
spring: +WhenmyApphas thedevprofile enabled, properties written to all of the above paths would be available to it, with properties in the first path in the list taking priority over the others.The configuration server can access a Git or Vault backend through an HTTP or HTTPS proxy. This behavior is controlled for either Git or Vault by settings under
proxy.httpandproxy.https. These settings are per repository, so if you are using a composite environment repository you must configure proxy settings for each backend in the composite individually. If using a network which requires separate proxy servers for HTTP and HTTPS URLs, you can configure both the HTTP and the HTTPS proxy settings for a single backend.The following table describes the proxy configuration properties for both HTTP and HTTPS proxies. All of these properties must be prefixed by
proxy.httporproxy.https.Table 2.2. Proxy Configuration Properties
Property Name Remarks host
The host of the proxy.
port
The port with which to access the proxy.
nonProxyHosts
Any hosts which the configuration server should access outside the proxy. If values are provided for both
proxy.http.nonProxyHostsandproxy.https.nonProxyHosts, theproxy.httpvalue will be used.username
The username with which to authenticate to the proxy. If values are provided for both
proxy.http.usernameandproxy.https.username, theproxy.httpvalue will be used.password
The password with which to authenticate to the proxy. If values are provided for both
proxy.http.passwordandproxy.https.password, theproxy.httpvalue will be used.The following configuration uses an HTTPS proxy to access a Git repository.
spring: profiles: active: git cloud: @@ -308,7 +308,7 @@ WhenmyApphas thedevusername: myproxyusername nonProxyHosts: example.comSharing configuration between all applications varies according to which approach you take, as described in the following topics:
With file-based (git, svn, and native) repositories, resources with file names in
application*(application.properties,application.yml,application-*.properties, and so on) are shared between all client applications. You can use resources with these file names to configure global defaults and have them be overridden by application-specific files as necessary.The #_property_overrides[property overrides] feature can also be used for setting global defaults, with placeholders applications -allowed to override them locally.
Tip With the “native” profile (a local file system backend) , you should use an explicit search location that is not part of the server’s own configuration. +allowed to override them locally.
Tip With the “native” profile (a local file system backend) , you should use an explicit search location that is not part of the server’s own configuration. Otherwise, the
application*resources in the default search locations get removed because they are part of the server.When using Vault as a backend, you can share configuration with all applications by placing configuration in
secret/application. For example, if you run the following Vault command, all applications using the config server will have the propertiesfooandbazavailable to them:$ vault write secret/application foo=bar baz=bamSpring Cloud Config Server supports JDBC (relational database) as a backend for configuration properties. You can enable this feature by adding
spring-jdbcto the classpath and using thejdbcprofile or by adding a bean of typeJdbcEnvironmentRepository. @@ -353,7 +353,7 @@ The priority order of a repository helps resolve any potential conflicts between If you have an environment similar to those in the preceding examples and you request configuration data with themasterlabel but the Subversion repository does not contain a branch calledmaster, the entire request fails.In addition to using one of the environment repositories from Spring Cloud, you can also provide your own
EnvironmentRepositorybean to be included as part of a composite environment. To do so, your bean must implement theEnvironmentRepositoryinterface. If you want to control the priority of your customEnvironmentRepositorywithin the composite environment, you should also implement theOrderedinterface and override thegetOrderedmethod. -If you do not implement theOrderedinterface, yourEnvironmentRepositoryis given the lowest priority.The Config Server has an “overrides” feature that lets the operator provide configuration properties to all applications. The overridden properties cannot be accidentally changed by the application with the normal Spring Boot hooks. To declare overrides, add a map of name-value pairs to
spring.cloud.config.server.overrides, as shown in the following example:spring: cloud: @@ -377,9 +377,9 @@ By default, it asks theEnvironmentRepositoryfor a name: myservice profiles: developmentYou can disable the Health Indicator by setting
spring.cloud.config.server.health.enabled=false.You can secure your Config Server in any way that makes sense to you (from physical network security to OAuth2 bearer tokens), because Spring Security and Spring Boot offer support for many security arrangements.
To use the default Spring Boot-configured HTTP Basic security, include Spring Security on the classpath (for example, through
spring-boot-starter-security). The default is a username ofuserand a randomly generated password. A random password is not useful in practice, so we recommend you configure the password (by settingspring.security.user.password) and encrypt it (see below for instructions on how to do that).
Important To use the encryption and decryption features you need the full-strength JCE installed in your JVM (it is not included by default). -You can download the “Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files” from Oracle and follow the installation instructions (essentially, you need to replace the two policy files in the JRE lib/security directory with the ones that you downloaded).
If the remote property sources contain encrypted content (values starting with
{cipher}), they are decrypted before sending to clients over HTTP. -The main advantage of this setup is that the property values need not be in plain text when they are “at rest” (for example, in a git repository). -If a value cannot be decrypted, it is removed from the property source and an additional property is added with the same key but prefixed withinvalidand a value that means “not applicable” (usually<n/a>). +You can download the “Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files” from Oracle and follow the installation instructions (essentially, you need to replace the two policy files in the JRE lib/security directory with the ones that you downloaded).If the remote property sources contain encrypted content (values starting with
{cipher}), they are decrypted before sending to clients over HTTP. +The main advantage of this setup is that the property values need not be in plain text when they are “at rest” (for example, in a git repository). +If a value cannot be decrypted, it is removed from the property source and an additional property is added with the same key but prefixed withinvalidand a value that means “not applicable” (usually<n/a>). This is largely to prevent cipher text being used as a password and accidentally leaking.If you set up a remote config repository for config client applications, it might contain an
application.ymlsimilar to the following:application.yml.
spring: datasource: @@ -402,7 +402,7 @@ mysecretTo use a key in a file (such as an RSA public key for encryptio the key value with "@" and provide the file path, as shown in the following example:
$ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...
Note The
--keyargument is mandatory (despite having a--prefix).The Config Server can use a symmetric (shared) key or an asymmetric one (RSA key pair). The asymmetric choice is superior in terms of security, but it is often more convenient to use a symmetric key since it is a single property value to configure in the
bootstrap.properties.To configure a symmetric key, you need to set
encrypt.keyto a secret String (or use theENCRYPT_KEYenvironment variable to keep it out of plain-text configuration files).To configure an asymmetric key, you can either set the key as a PEM-encoded text value (in
encrypt.key) or use a keystore (such as the keystore created by thekeytoolutility that comes with the JDK). -The following table describes the keystore properties:
Property Description
encrypt.keyStore.locationContains a
Resourcelocation
encrypt.keyStore.passwordHolds the password that unlocks the keystore
encrypt.keyStore.aliasIdentifies which key in the store to use
The encryption is done with the public key, and a private key is +The following table describes the keystore properties:
Property Description
encrypt.keyStore.locationContains a
Resourcelocation
encrypt.keyStore.passwordHolds the password that unlocks the keystore
encrypt.keyStore.aliasIdentifies which key in the store to use
The encryption is done with the public key, and a private key is needed for decryption. Thus, in principle, you can configure only the public key in the server if you want to only encrypt (and are prepared to decrypt the values yourself locally with the private key). In practice, you might not want to do decrypt locally, because it spreads the key management process around all the clients, instead of diff --git a/multi/multi_pr01.html b/multi/multi_pr01.html index e8b650b3..431f0206 100644 --- a/multi/multi_pr01.html +++ b/multi/multi_pr01.html @@ -1,6 +1,6 @@
-2.1.0.BUILD-SNAPSHOT
Spring Cloud Config provides server-side and client-side support for externalized configuration in a distributed system. With the Config Server, you have a central place to manage external properties for applications across all environments. +
2.1.0.BUILD-SNAPSHOT
Spring Cloud Config provides server-side and client-side support for externalized configuration in a distributed system. With the Config Server, you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring
-EnvironmentandPropertySourceabstractions, so they fit very well with Spring applications but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production, you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git, so it easily supports labelled versions of configuration environments as well as being accessible to a wide range of tooling for managing the content. diff --git a/multi/multi_spring-cloud-config.html b/multi/multi_spring-cloud-config.html index 290fd3c5..ec1257db 100644 --- a/multi/multi_spring-cloud-config.html +++ b/multi/multi_spring-cloud-config.html @@ -1,3 +1,3 @@Spring Cloud Config \ No newline at end of file +Table of Contents
- 1. Quick Start
- 2. Spring Cloud Config Server
- 2.1. Environment Repository
- 2.1.1. Git Backend
- Skipping SSL Certificate Validation
- Setting HTTP Connection Timeout
- Placeholders in Git URI
- Pattern Matching and Multiple Repositories
- Authentication
- Authentication with AWS CodeCommit
- Git SSH configuration using properties
- Placeholders in Git Search Paths
- Force pull in Git Repositories
- Deleting untracked branches in Git Repositories
- 2.1.2. Version Control Backend Filesystem Use
- 2.1.3. File System Backend
- 2.1.4. Vault Backend
- 2.1.5. Accessing Backends Through a Proxy
- 2.1.6. Sharing Configuration With All Applications
- 2.1.7. JDBC Backend
- 2.1.8. Composite Environment Repositories
- 2.1.9. Property Overrides
- 2.2. Health Indicator
- 2.3. Security
- 2.4. Encryption and Decryption
- 2.5. Key Management
- 2.6. Creating a Key Store for Testing
- 2.7. Using Multiple Keys and Key Rotation
- 2.8. Serving Encrypted Properties
- 3. Serving Alternative Formats
- 4. Serving Plain Text
- 5. Embedding the Config Server
- 6. Push Notifications and Spring Cloud Bus
- 7. Spring Cloud Config Client
Spring Cloud Config \ No newline at end of file diff --git a/single/spring-cloud-config.html b/single/spring-cloud-config.html index 6785d9d8..680a5143 100644 --- a/single/spring-cloud-config.html +++ b/single/spring-cloud-config.html @@ -1,6 +1,6 @@ -Table of Contents
- 1. Quick Start
- 2. Spring Cloud Config Server
- 2.1. Environment Repository
- 2.1.1. Git Backend
- Skipping SSL Certificate Validation
- Setting HTTP Connection Timeout
- Placeholders in Git URI
- Pattern Matching and Multiple Repositories
- Authentication
- Authentication with AWS CodeCommit
- Git SSH configuration using properties
- Placeholders in Git Search Paths
- Force pull in Git Repositories
- Deleting untracked branches in Git Repositories
- 2.1.2. Version Control Backend Filesystem Use
- 2.1.3. File System Backend
- 2.1.4. Vault Backend
- 2.1.5. Accessing Backends Through a Proxy
- 2.1.6. Sharing Configuration With All Applications
- 2.1.7. JDBC Backend
- 2.1.8. Composite Environment Repositories
- 2.1.9. Property Overrides
- 2.2. Health Indicator
- 2.3. Security
- 2.4. Encryption and Decryption
- 2.5. Key Management
- 2.6. Creating a Key Store for Testing
- 2.7. Using Multiple Keys and Key Rotation
- 2.8. Serving Encrypted Properties
- 3. Serving Alternative Formats
- 4. Serving Plain Text
- 5. Embedding the Config Server
- 6. Push Notifications and Spring Cloud Bus
- 7. Spring Cloud Config Client
Spring Cloud Config Table of Contents
- 1. Quick Start
- 2. Spring Cloud Config Server
- 2.1. Environment Repository
- 2.1.1. Git Backend
- Skipping SSL Certificate Validation
- Setting HTTP Connection Timeout
- Placeholders in Git URI
- Pattern Matching and Multiple Repositories
- Authentication
- Authentication with AWS CodeCommit
- Git SSH configuration using properties
- Placeholders in Git Search Paths
- Force pull in Git Repositories
- Deleting untracked branches in Git Repositories
- 2.1.2. Version Control Backend Filesystem Use
- 2.1.3. File System Backend
- 2.1.4. Vault Backend
- 2.1.5. Accessing Backends Through a Proxy
- 2.1.6. Sharing Configuration With All Applications
- 2.1.7. JDBC Backend
- 2.1.8. Composite Environment Repositories
- 2.1.9. Property Overrides
- 2.2. Health Indicator
- 2.3. Security
- 2.4. Encryption and Decryption
- 2.5. Key Management
- 2.6. Creating a Key Store for Testing
- 2.7. Using Multiple Keys and Key Rotation
- 2.8. Serving Encrypted Properties
- 3. Serving Alternative Formats
- 4. Serving Plain Text
- 5. Embedding the Config Server
- 6. Push Notifications and Spring Cloud Bus
- 7. Spring Cloud Config Client
2.1.0.BUILD-SNAPSHOT
Spring Cloud Config provides server-side and client-side support for externalized configuration in a distributed system. With the Config Server, you have a central place to manage external properties for applications across all environments. +
Spring Cloud Config Table of Contents
- 1. Quick Start
- 2. Spring Cloud Config Server
- 2.1. Environment Repository
- 2.1.1. Git Backend
- Skipping SSL Certificate Validation
- Setting HTTP Connection Timeout
- Placeholders in Git URI
- Pattern Matching and Multiple Repositories
- Authentication
- Authentication with AWS CodeCommit
- Git SSH configuration using properties
- Placeholders in Git Search Paths
- Force pull in Git Repositories
- Deleting untracked branches in Git Repositories
- 2.1.2. Version Control Backend Filesystem Use
- 2.1.3. File System Backend
- 2.1.4. Vault Backend
- 2.1.5. Accessing Backends Through a Proxy
- 2.1.6. Sharing Configuration With All Applications
- 2.1.7. JDBC Backend
- 2.1.8. Composite Environment Repositories
- 2.1.9. Property Overrides
- 2.2. Health Indicator
- 2.3. Security
- 2.4. Encryption and Decryption
- 2.5. Key Management
- 2.6. Creating a Key Store for Testing
- 2.7. Using Multiple Keys and Key Rotation
- 2.8. Serving Encrypted Properties
- 3. Serving Alternative Formats
- 4. Serving Plain Text
- 5. Embedding the Config Server
- 6. Push Notifications and Spring Cloud Bus
- 7. Spring Cloud Config Client
2.1.0.BUILD-SNAPSHOT
Spring Cloud Config provides server-side and client-side support for externalized configuration in a distributed system. With the Config Server, you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring
EnvironmentandPropertySourceabstractions, so they fit very well with Spring applications but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production, you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git, so it easily supports labelled versions of configuration environments as well as being accessible to a wide range of tooling for managing the content. @@ -144,12 +144,12 @@ If you use a command-line client such as curl, be careful with the brackets in t git: uri: https://example.com/my/repo timeout: 4Spring Cloud Config Server supports a git repository URL with placeholders for the
{application}and{profile}(and{label}if you need it, but remember that the label is applied as a git label anyway). -So you can support a “one repository per application” policy by using a structure similar to the following:spring: +So you can support a “one repository per application” policy by using a structure similar to the following:spring: cloud: config: server: git: - uri: https://github.com/myorg/{application}You can also support a “one repository per profile” policy by using a similar pattern but with + uri: https://github.com/myorg/{application}
You can also support a “one repository per profile” policy by using a similar pattern but with
{profile}.Additionally, using the special string "(_)" within your
{application}parameters can enable support for multiple organizations, as shown in the following example:spring: cloud: @@ -172,7 +172,7 @@ The pattern format is a comma-separated list of{applicati local: pattern: local* uri: file:/home/configsvc/config-repoIf
{application}/{profile}does not match any of the patterns, it uses the default URI defined underspring.cloud.config.server.git.uri. -In the above example, for the “simple” repository, the pattern issimple/*(it only matches one application namedsimplein all profiles). The “local” repository matches all application names beginning withlocalin all profiles (the/*suffix is added automatically to any pattern that does not have a profile matcher).
Note The “one-liner” short cut used in the “simple” example can be used only if the only property to be set is the URI. +In the above example, for the “simple” repository, the pattern is
simple/*(it only matches one application namedsimplein all profiles). The “local” repository matches all application names beginning withlocalin all profiles (the/*suffix is added automatically to any pattern that does not have a profile matcher).
Note The “one-liner” short cut used in the “simple” example can be used only if the only property to be set is the URI. If you need to set anything else (credentials, pattern, and so on) you need to use the full form.
The
patternproperty in the repo is actually an array, so you can use a YAML array (or[0],[1], etc. suffixes in properties files) to bind to multiple patterns. You may need to do so if you are going to run apps with multiple profiles, as shown in the following example:spring: cloud: @@ -191,7 +191,7 @@ You may need to do so if you are going to run apps with multiple profiles, as sh - '*/qa' - '*/production' uri: https://github.com/staging/config-repo
Note Spring Cloud guesses that a pattern containing a profile that does not end in
*implies that you actually want to match a list of profiles starting with this pattern (so*/stagingis a shortcut for["*/staging", "*/staging,*"], and so on). -This is common where, for instance, you need to run applications in the “development” profile locally but also the “cloud” profile remotely.Every repository can also optionally store config files in sub-directories, and patterns to search for those directories can be specified as
searchPaths. +This is common where, for instance, you need to run applications in the “development” profile locally but also the “cloud” profile remotely.Every repository can also optionally store config files in sub-directories, and patterns to search for those directories can be specified as
searchPaths. The following example shows a config file at the top level:spring: cloud: config: @@ -279,7 +279,7 @@ In order to activate property-based SSH configuration, the69pcVH/4rmLbXdcmNYGm6iu+MlPQk4BUZknHSmVHIFdJ0EPupVaQ8RHT - -----END RSA PRIVATE KEY-----The following table describes the SSH configuration properties.
Table 2.1. SSH Configuration Properties
Property Name Remarks ignoreLocalSshSettings
If
true, use property-based instead of file-based SSH config. Must be set at asspring.cloud.config.server.git.ignoreLocalSshSettings, not inside a repository definition.privateKey
Valid SSH private key. Must be set if
ignoreLocalSshSettingsis true and Git URI is SSH format.hostKey
Valid SSH host key. Must be set if
hostKeyAlgorithmis also set.hostKeyAlgorithm
One of
ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, or ecdsa-sha2-nistp521. Must be set ifhostKeyis also set.strictHostKeyChecking
trueorfalse. If false, ignore errors with host key.knownHostsFile
Location of custom
.known_hostsfile.preferredAuthentications
Override server authentication method order. This should allow for evading login prompts if server has keyboard-interactive authentication before the
publickeymethod.Spring Cloud Config Server also supports a search path with placeholders for the
{application}and{profile}(and{label}if + -----END RSA PRIVATE KEY-----The following table describes the SSH configuration properties.
Table 2.1. SSH Configuration Properties
Property Name Remarks ignoreLocalSshSettings
If
true, use property-based instead of file-based SSH config. Must be set at asspring.cloud.config.server.git.ignoreLocalSshSettings, not inside a repository definition.privateKey
Valid SSH private key. Must be set if
ignoreLocalSshSettingsis true and Git URI is SSH format.hostKey
Valid SSH host key. Must be set if
hostKeyAlgorithmis also set.hostKeyAlgorithm
One of
ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, or ecdsa-sha2-nistp521. Must be set ifhostKeyis also set.strictHostKeyChecking
trueorfalse. If false, ignore errors with host key.knownHostsFile
Location of custom
.known_hostsfile.preferredAuthentications
Override server authentication method order. This should allow for evading login prompts if server has keyboard-interactive authentication before the
publickeymethod.Spring Cloud Config Server also supports a search path with placeholders for the
{application}and{profile}(and{label}if you need it), as shown in the following example:spring: cloud: config: @@ -330,7 +330,7 @@ By default, they are put in the system temporary directory with a prefix of/tmp/config-repo-<randomid>. Some operating systems routinely clean out temporary directories. This can lead to unexpected behavior, such as missing properties. -To avoid this problem, change the directory that Config Server uses by setting spring.cloud.config.server.git.basedirorspring.cloud.config.server.svn.basedirto a directory that does not reside in the system temp structure.There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with
spring.cloud.config.server.native.searchLocations). +To avoid this problem, change the directory that Config Server uses by settingspring.cloud.config.server.git.basedirorspring.cloud.config.server.svn.basedirto a directory that does not reside in the system temp structure.There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with
spring.cloud.config.server.native.searchLocations). To use the native profile, launch the Config Server withspring.profiles.active=native.
Note Remember to use the
file:prefix for file resources (the default without a prefix is usually the classpath). As with any Spring Boot configuration, you can embed${}-style environment placeholders, but remember that absolute paths in Windows require an extra/(for example,file:///${user.home}/config-repo).
Warning The default value of the
searchLocationsis identical to a local Spring Boot application (that is,[classpath:/, classpath:/config, file:./, file:./config]). @@ -339,12 +339,12 @@ To use it in production, you need to be sure that the file system is reliable an In this way, you can segregate the directories in the path and choose a strategy that makes sense for you (such as subdirectory per application or subdirectory per profile).If you do not use placeholders in the search locations, this repository also appends the
{label}parameter of the HTTP resource to a suffix on the search path, so properties files are loaded from each search location and a subdirectory with the same name as the label (the labelled properties take precedence in the Spring Environment). Thus, the default behaviour with no placeholders is the same as adding a search location ending with/{label}/. For example,file:/tmp/configis the same asfile:/tmp/config,file:/tmp/config/{label}. -This behavior can be disabled by settingspring.cloud.config.server.native.addLabelLocations=false.Spring Cloud Config Server also supports Vault as a backend.
Spring Cloud Config Server also supports Vault as a backend.
For more information on Vault, see the Vault quick start guide.
To enable the config server to use a Vault backend, you can run your config server with the
vaultprofile. For example, in your config server’sapplication.properties, you can addspring.profiles.active=vault.By default, the config server assumes that your Vault server runs at
http://127.0.0.1:8200. It also assumes that the name of backend issecretand the key isapplication. All of these defaults can be configured in your config server’sapplication.properties. -The following table describes configurable Vault properties:
Name Default Value host
127.0.0.1
port
8200
scheme
http
backend
secret
defaultKey
application
profileSeparator
,
kvVersion
1
skipSslValidation
false
timeout
5
Important All of the properties in the preceding table must be prefixed with
spring.cloud.config.server.vault.All configurable properties can be found in
org.springframework.cloud.config.server.environment.VaultEnvironmentRepository.Vault 0.10.0 introduced a versioned key-value backend (k/v backend version 2) that exposes a different API than earlier versions, it now requires a
data/between the mount path and the actual context path and wraps secrets in adataobject. SettingkvVersion=2will take this into account.With your config server running, you can make HTTP requests to the server to retrieve +The following table describes configurable Vault properties:
Name Default Value host
127.0.0.1
port
8200
scheme
http
backend
secret
defaultKey
application
profileSeparator
,
kvVersion
1
skipSslValidation
false
timeout
5
Important All of the properties in the preceding table must be prefixed with
spring.cloud.config.server.vault.All configurable properties can be found in
org.springframework.cloud.config.server.environment.VaultEnvironmentRepository.Vault 0.10.0 introduced a versioned key-value backend (k/v backend version 2) that exposes a different API than earlier versions, it now requires a
data/between the mount path and the actual context path and wraps secrets in adataobject. SettingkvVersion=2will take this into account.With your config server running, you can make HTTP requests to the server to retrieve values from the Vault backend. To do so, you need a token for your Vault server.
First, place some data in you Vault, as shown in the following example:
$ vault write secret/application foo=bar baz=bam $ vault write secret/myapp foo=myappsbarSecond, make an HTTP request to your config server to retrieve the values, as shown in the following example:
$ curl -X "GET" "http://localhost:8888/myapp/default" -H "X-Config-Token: yourtoken"You should see a response similar to the following:
{ @@ -376,7 +376,7 @@ secret/myApp secret/application,dev secret/applicationProperties written to
secret/applicationare available to all applications using the Config Server. An application with the name,myApp, would have any properties written tosecret/myAppandsecret/applicationavailable to it. -WhenmyApphas thedevprofile enabled, properties written to all of the above paths would be available to it, with properties in the first path in the list taking priority over the others.The configuration server can access a Git or Vault backend through an HTTP or HTTPS proxy. This behavior is controlled for either Git or Vault by settings under
proxy.httpandproxy.https. These settings are per repository, so if you are using a composite environment repository you must configure proxy settings for each backend in the composite individually. If using a network which requires separate proxy servers for HTTP and HTTPS URLs, you can configure both the HTTP and the HTTPS proxy settings for a single backend.The following table describes the proxy configuration properties for both HTTP and HTTPS proxies. All of these properties must be prefixed by
proxy.httporproxy.https.Table 2.2. Proxy Configuration Properties
Property Name Remarks host
The host of the proxy.
port
The port with which to access the proxy.
nonProxyHosts
Any hosts which the configuration server should access outside the proxy. If values are provided for both
proxy.http.nonProxyHostsandproxy.https.nonProxyHosts, theproxy.httpvalue will be used.username
The username with which to authenticate to the proxy. If values are provided for both
proxy.http.usernameandproxy.https.username, theproxy.httpvalue will be used.password
The password with which to authenticate to the proxy. If values are provided for both
proxy.http.passwordandproxy.https.password, theproxy.httpvalue will be used.The following configuration uses an HTTPS proxy to access a Git repository.
spring: +WhenmyApphas thedevprofile enabled, properties written to all of the above paths would be available to it, with properties in the first path in the list taking priority over the others.The configuration server can access a Git or Vault backend through an HTTP or HTTPS proxy. This behavior is controlled for either Git or Vault by settings under
proxy.httpandproxy.https. These settings are per repository, so if you are using a composite environment repository you must configure proxy settings for each backend in the composite individually. If using a network which requires separate proxy servers for HTTP and HTTPS URLs, you can configure both the HTTP and the HTTPS proxy settings for a single backend.The following table describes the proxy configuration properties for both HTTP and HTTPS proxies. All of these properties must be prefixed by
proxy.httporproxy.https.Table 2.2. Proxy Configuration Properties
Property Name Remarks host
The host of the proxy.
port
The port with which to access the proxy.
nonProxyHosts
Any hosts which the configuration server should access outside the proxy. If values are provided for both
proxy.http.nonProxyHostsandproxy.https.nonProxyHosts, theproxy.httpvalue will be used.username
The username with which to authenticate to the proxy. If values are provided for both
proxy.http.usernameandproxy.https.username, theproxy.httpvalue will be used.password
The password with which to authenticate to the proxy. If values are provided for both
proxy.http.passwordandproxy.https.password, theproxy.httpvalue will be used.The following configuration uses an HTTPS proxy to access a Git repository.
spring: profiles: active: git cloud: @@ -392,7 +392,7 @@ WhenmyApphas thedevusername: myproxyusername nonProxyHosts: example.comSharing configuration between all applications varies according to which approach you take, as described in the following topics:
With file-based (git, svn, and native) repositories, resources with file names in
application*(application.properties,application.yml,application-*.properties, and so on) are shared between all client applications. You can use resources with these file names to configure global defaults and have them be overridden by application-specific files as necessary.The #_property_overrides[property overrides] feature can also be used for setting global defaults, with placeholders applications -allowed to override them locally.
Tip With the “native” profile (a local file system backend) , you should use an explicit search location that is not part of the server’s own configuration. +allowed to override them locally.
Tip With the “native” profile (a local file system backend) , you should use an explicit search location that is not part of the server’s own configuration. Otherwise, the
application*resources in the default search locations get removed because they are part of the server.When using Vault as a backend, you can share configuration with all applications by placing configuration in
secret/application. For example, if you run the following Vault command, all applications using the config server will have the propertiesfooandbazavailable to them:$ vault write secret/application foo=bar baz=bamSpring Cloud Config Server supports JDBC (relational database) as a backend for configuration properties. You can enable this feature by adding
spring-jdbcto the classpath and using thejdbcprofile or by adding a bean of typeJdbcEnvironmentRepository. @@ -437,7 +437,7 @@ The priority order of a repository helps resolve any potential conflicts between If you have an environment similar to those in the preceding examples and you request configuration data with themasterlabel but the Subversion repository does not contain a branch calledmaster, the entire request fails.In addition to using one of the environment repositories from Spring Cloud, you can also provide your own
EnvironmentRepositorybean to be included as part of a composite environment. To do so, your bean must implement theEnvironmentRepositoryinterface. If you want to control the priority of your customEnvironmentRepositorywithin the composite environment, you should also implement theOrderedinterface and override thegetOrderedmethod. -If you do not implement theOrderedinterface, yourEnvironmentRepositoryis given the lowest priority.The Config Server has an “overrides” feature that lets the operator provide configuration properties to all applications. The overridden properties cannot be accidentally changed by the application with the normal Spring Boot hooks. To declare overrides, add a map of name-value pairs to
spring.cloud.config.server.overrides, as shown in the following example:spring: cloud: @@ -461,9 +461,9 @@ By default, it asks theEnvironmentRepositoryfor a name: myservice profiles: developmentYou can disable the Health Indicator by setting
spring.cloud.config.server.health.enabled=false.You can secure your Config Server in any way that makes sense to you (from physical network security to OAuth2 bearer tokens), because Spring Security and Spring Boot offer support for many security arrangements.
To use the default Spring Boot-configured HTTP Basic security, include Spring Security on the classpath (for example, through
spring-boot-starter-security). The default is a username ofuserand a randomly generated password. A random password is not useful in practice, so we recommend you configure the password (by settingspring.security.user.password) and encrypt it (see below for instructions on how to do that).
Important To use the encryption and decryption features you need the full-strength JCE installed in your JVM (it is not included by default). -You can download the “Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files” from Oracle and follow the installation instructions (essentially, you need to replace the two policy files in the JRE lib/security directory with the ones that you downloaded).
If the remote property sources contain encrypted content (values starting with
{cipher}), they are decrypted before sending to clients over HTTP. -The main advantage of this setup is that the property values need not be in plain text when they are “at rest” (for example, in a git repository). -If a value cannot be decrypted, it is removed from the property source and an additional property is added with the same key but prefixed withinvalidand a value that means “not applicable” (usually<n/a>). +You can download the “Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files” from Oracle and follow the installation instructions (essentially, you need to replace the two policy files in the JRE lib/security directory with the ones that you downloaded).If the remote property sources contain encrypted content (values starting with
{cipher}), they are decrypted before sending to clients over HTTP. +The main advantage of this setup is that the property values need not be in plain text when they are “at rest” (for example, in a git repository). +If a value cannot be decrypted, it is removed from the property source and an additional property is added with the same key but prefixed withinvalidand a value that means “not applicable” (usually<n/a>). This is largely to prevent cipher text being used as a password and accidentally leaking.If you set up a remote config repository for config client applications, it might contain an
application.ymlsimilar to the following:application.yml.
spring: datasource: @@ -486,7 +486,7 @@ mysecretTo use a key in a file (such as an RSA public key for encryptio the key value with "@" and provide the file path, as shown in the following example:
$ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...
Note The
--keyargument is mandatory (despite having a--prefix).The Config Server can use a symmetric (shared) key or an asymmetric one (RSA key pair). The asymmetric choice is superior in terms of security, but it is often more convenient to use a symmetric key since it is a single property value to configure in the
bootstrap.properties.To configure a symmetric key, you need to set
encrypt.keyto a secret String (or use theENCRYPT_KEYenvironment variable to keep it out of plain-text configuration files).To configure an asymmetric key, you can either set the key as a PEM-encoded text value (in
encrypt.key) or use a keystore (such as the keystore created by thekeytoolutility that comes with the JDK). -The following table describes the keystore properties:
Property Description
encrypt.keyStore.locationContains a
Resourcelocation
encrypt.keyStore.passwordHolds the password that unlocks the keystore
encrypt.keyStore.aliasIdentifies which key in the store to use
The encryption is done with the public key, and a private key is +The following table describes the keystore properties:
Property Description
encrypt.keyStore.locationContains a
Resourcelocation
encrypt.keyStore.passwordHolds the password that unlocks the keystore
encrypt.keyStore.aliasIdentifies which key in the store to use
The encryption is done with the public key, and a private key is needed for decryption. Thus, in principle, you can configure only the public key in the server if you want to only encrypt (and are prepared to decrypt the values yourself locally with the private key). In practice, you might not want to do decrypt locally, because it spreads the key management process around all the clients, instead of @@ -563,7 +563,7 @@ In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, Doing so broadcasts to applications matching the
{name}pattern (which can contain wildcards).
Note The
RefreshRemoteApplicationEventis transmitted only if thespring-cloud-busis activated in both the Config Server and in the client application.
Note The default configuration also detects filesystem changes in local git repositories. In that case, the webhook is not used. However, as soon as you edit a config file, a refresh is broadcast.
A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources provided by the application developer). It also picks up some additional useful features related to
Environmentchange events.The default behavior for any application that has the Spring Cloud Config Client on the classpath is as follows: When a config client starts, it binds to the Config Server (through the
spring.cloud.config.uribootstrap configuration property) and initializes SpringEnvironmentwith remote property sources.The net result of this behavior is that all client applciations that want to consume the Config Server need a
bootstrap.yml(or an environment variable) with the server address set inspring.cloud.config.uri(it defaults to "http://localhost:8888").If you use a `DiscoveryClient implementation, such as Spring Cloud Netflix and Eureka Service Discovery or Spring Cloud Consul, you can have the Config Server register with the Discovery Service. -However, in the default “Config First” mode, clients cannot take advantage of the registration.
If you prefer to use
DiscoveryClientto locate the Config Server, you can do so by settingspring.cloud.config.discovery.enabled=true(the default isfalse). +However, in the default “Config First” mode, clients cannot take advantage of the registration.If you prefer to use
DiscoveryClientto locate the Config Server, you can do so by settingspring.cloud.config.discovery.enabled=true(the default isfalse). The net result of doing so is that client applications all need abootstrap.yml(or an environment variable) with the appropriate discovery configuration. For example, with Spring Cloud Netflix, you need to define the Eureka server address (for example, ineureka.client.serviceUrl.defaultZone). The price for using this option is an extra network round trip on startup, to locate the service registration. diff --git a/spring-cloud-config.html b/spring-cloud-config.html index 4055a60e..452f8d3f 100644 --- a/spring-cloud-config.html +++ b/spring-cloud-config.html @@ -4,7 +4,7 @@ - +spring-cloud-config