有人知道如何配置bootstrap.yml
来告诉Spring Cloud Vault转到k2 v2的正确路径,而不先尝试其他路径吗?
我可以成功地连接到运行k2 v2的保管库,但是Spring Cloud将始终尝试连接到保管库中不存在的路径,并在启动时抛出403。
Status 403 Forbidden [secret/application]: permission denied; nested exception is org.springframework.web.client.HttpClientErrorException$Forbidden: 403 Forbidden
上面的路径secret/application
不存在,因为k2 v2将data
放在路径中。例如:secret/data/application
。
这不是停止显示的方法,因为Spring Cloud Vault 确实会检查其他路径,包括路径中带有data
项的正确路径,但事实是毫无意义的403在启动过程中抛出的东西就像是我脑海中的碎片。
最终,它会尝试正确的k2 v2路径
2019-03-18 12:22:46.611 INFO 77685 --- [ restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='vault', propertySources=[LeaseAwareVaultPropertySource {name='secret/data/my-app'}
spring.cloud.vault:
kv:
enabled: true
backend: secret
profile-separator: '/'
default-context: my-app
application-name: my-app
host: localhost
port: 8200
scheme: http
authentication: TOKEN
token: my-crazy-long-token-string
感谢您的帮助!
答案 0 :(得分:0)
在bootstrap.yml中添加以下行,这将禁用通用后端
spring.cloud.vault:
generic:
enabled: false
有关更多信息,https://cloud.spring.io/spring-cloud-vault/reference/html/#vault.config.backends.generic
答案 1 :(得分:0)
除了已接受的答案之外,关闭(或仅删除)fail-fast
选项也很重要:
spring.cloud.vault:
fail-fast: false