Spring Config Server:使用特定路径从Vault获取机密

我正在尝试从连接到两个源的配置服务器获取我的微服务配置:git和Vault(用于秘密)。我有下面的配置: 在配置服务器中:

server:
  port: 8888

spring:
  profiles:
    active: git,vault
  cloud:
    config:
      server:
        vault:
          port: 8200
          host: 127.0.0.1
          kvVersion: 2
        git:
          order: 2
          uri: git@gitlab.git

并在bootstrap.yml的客户端中:

spring:
  application:
    name: my-service-name

  cloud:
    config:
      uri: http://localhost:8888
      token: //token
      label: dev

但是在我的保险库中,我的路径是这样的:

secret/cad
     |--my-service-name

当我直接在/secret/my-service-name中创建秘密时,我可以访问我的秘密,但是如何在/secret/cad/my-service-name

中配置对秘密的访问权限

谢谢。

iCMS 回答:Spring Config Server:使用特定路径从Vault获取机密

您可以创建实现VaultConfigurer的自定义配置类,在其中可以覆盖自定义路径

@配置 公共类CustomVaultConfiguraton实现VaultConfigurer {

 @override
 public void addSecretsBackends(SecretBackendConfigurer configures){

 configures.add("customPath");

} }

在spring.factories中添加上述配置类 org.springframework.cloud.bootstrap.BootstrapConfiguration = \ packagename.CustomVaultConfiguration

本文链接:https://www.f2er.com/1571598.html

大家都在问