【问题标题】:Spring Config Server : get secrets from vault with specific pathSpring Config Server:从具有特定路径的库中获取机密
【发布时间】:2021-01-01 08:15:44
【问题描述】:

我正在尝试从连接到 2 个源的配置服务器获取我的微服务配置: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

谢谢。

【问题讨论】:

    标签: spring hashicorp-vault spring-cloud-vault-config


    【解决方案1】:

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

    @配置 公共类 CustomVaultConfiguraton 实现 VaultConfigurer {

     @override
     public void addSecretsBackends(SecretBackendConfigurer configures){
    
     configures.add("customPath");
    

    } }

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

    【讨论】:

      猜你喜欢
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2016-05-28
      • 2019-11-28
      相关资源
      最近更新 更多