我正在使用Spring Cloud Config Server爲我的客戶端應用程序提供配置。爲了促進祕密配置,我使用HashiCorp Vault作爲後端。對於配置的其餘部分,我使用GIT repo。所以我已經在複合模式下配置了配置服務器。請參閱下面我的配置服務器bootstrap.yml
: -Spring Cloud Config(Vault後端)過早提早
server:
port: 8888
spring:
profiles:
active: local, git, vault
application:
name: my-domain-configuration-server
cloud:
config:
server:
git:
uri: https://mygit/my-domain-configuration
order: 1
vault:
order: 2
host: vault.mydomain.com
port: 8200
scheme: https
backend: mymount/generic
這是所有工作正常。但是,我正在使用的令牌使用保險庫授權策略進行保護。見下文: -
{
"rules": "path "mymount/generic/myapp-app,local" {
policy = "read"
}
path "mymount/generic/myapp-app,local/*" {
policy = "read"
}
path "mymount/generic/myapp-app" {
policy = "read"
}
path "mymount/generic/myapp-app/*" {
policy = "read"
}
path "mymount/generic/application,local" {
policy = "read"
}
path "mymount/generic/application,local/*" {
policy = "read"
}
path "mymount/generic/application" {
policy = "read"
}
path "mymount/generic/application/*" {
policy = "read"
}"
}
我的問題是,我沒有在所有這些範圍內存儲祕密。我需要指定所有這些路徑,以便我可以授權令牌從mymount/generic/myapp-app,local
讀取一個祕密。如果我不授權所有其他路徑,則VaultEnvironmentRepository.read()
方法將返回狀態代碼(Forbidden)並引發VaultException。這導致完全無法檢索應用程序的任何配置,包括基於GIT的配置。這是非常有限的,因爲客戶端應用程序可能擁有多個與檢索配置項無關的Spring配置文件。問題是配置服務器將嘗試檢索客戶端提供的所有活動配置文件的配置。
有沒有辦法在配置服務器上啓用容錯或寬鬆,這樣VaultEnvironmentRepository不會中止並返回實際授權返回的配置?
同意,即使如此,我的問題也說明了如果我添加未在Vault中配置的任何配置文件仍然存在的問題。我需要一種機制,允許我使用未在保險櫃中配置的配置文件。這裏的「本地」配置文件僅僅是用於說明。 – Codesnooper