W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
Spring Cloud Config服務(wù)器支持CredHub作為配置屬性的后端。您可以通過向Spring CredHub添加依賴項來啟用此功能。
pom.xml。
<dependencies>
<dependency>
<groupId>org.springframework.credhub</groupId>
<artifactId>spring-credhub-starter</artifactId>
</dependency>
</dependencies>
以下配置使用雙向TLS訪問CredHub:
spring:
profiles:
active: credhub
cloud:
config:
server:
credhub:
url: https://credhub:8844
屬性應(yīng)存儲為JSON,例如:
credhub set --name "/demo-app/default/master/toggles" --type=json
value: {"toggle.button": "blue", "toggle.link": "red"}
credhub set --name "/demo-app/default/master/abs" --type=json
value: {"marketing.enabled": true, "external.enabled": false}
名稱為?spring.cloud.config.name=demo-app
?的所有客戶端應(yīng)用程序?qū)⒕哂幸韵聦傩裕?/p>
{
toggle.button: "blue",
toggle.link: "red",
marketing.enabled: true,
external.enabled: false
}
如果未指定配置文件,將使用
default
,而未指定標簽時,將使用master
作為默認值。注意:添加到application
的值將由所有應(yīng)用程序共享。
您可以使用UAA作為提供程序通過OAuth 2.0進行身份驗證。
pom.xml。
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
</dependencies>
以下配置使用OAuth 2.0和UAA訪問CredHub:
spring:
profiles:
active: credhub
cloud:
config:
server:
credhub:
url: https://credhub:8844
oauth2:
registration-id: credhub-client
security:
oauth2:
client:
registration:
credhub-client:
provider: uaa
client-id: credhub_config_server
client-secret: asecret
authorization-grant-type: client_credentials
provider:
uaa:
token-uri: https://uaa:8443/oauth/token
使用的UAA客戶ID的范圍應(yīng)為?
credhub.read
?。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: