Spring Cloud Vault不适用于自定义安装

时间:2018-10-17 18:30:35

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

在本地计算机上,我使用默认策略运行Vault服务器并写入了以下键值。

vault write secret/my-application username=Test

bootstrap.yml(正在运行)

spring:
  application:
    name: my-application
  cloud:
    vault:
      authentication: TOKEN
      token: sometoken
      host: localhost
      port: 8200
      scheme: http
      #uri: http://localhost:8200
      connection-timeout: 5000
      read-timeout: 15000
      config:
        order: -10

我能够使用Spring Cloud Vault来获取值,即当我使用默认挂载(秘密)时。但是,如果我使用自定义mount(group)进入质量检查服务器,则会收到以下错误。

org.springframework.vault.VaultException:状态403秘密/组/组类型/组名/数据库:权限被拒绝

(不确定为什么会加前缀secret)

bootstrap.yml(不起作用)

spring:
  application:
    name: group/grouptype/groupname/DB
  cloud:
    vault:
      authentication: TOKEN
      token: sometoken
      host: 10.20.30.40
      port: 8200
      scheme: http
      #uri: http://10.20.30.40:8200
      connection-timeout: 5000
      read-timeout: 15000
      config:
        order: -10

但是,如果我从POSTMAN中访问了API,它就会按预期运行。

GET
http://10.20.30.40:8200/v1/group/grouptype/groupname/DB
Header:  
X-Vault-Token:sometoken

如何使自定义代理与Spring Boot应用程序一起使用。如何从上下文中排除秘密

1 个答案:

答案 0 :(得分:0)

对于自定义安装,我们必须添加通用

declare @customerEvent table(CustomerEventID int not null primary key identity
                                , EventDate datetime)
declare @customerPurchase table(CustomerPurchaseID int not null primary key identity
                                , CustomerEventID int, ItemID varchar(100))

insert into @customerEvent(EventDate)
    values ('2018-01-01'), ('2018-01-02'), ('2018-01-03'), ('2018-01-04')
insert into @customerPurchase(CustomerEventID, ItemID)
    values (1, 1), (1, 2), (1, 3)
            , (2, 3), (2, 4), (2, 10)
            , (3, 1), (3, 2)
            , (4, 1)

-- if you want all the fields from CustomerPurchase Table
select  e.CustomerEventID
        , op.CustomerPurchaseID
from    @customerEvent as e
        outer apply (select top 1 p.* from @customerPurchase as p where p.CustomerEventID = e.CustomerEventID
                        order by CustomerPurchaseID desc) as op

-- if you want only the last CustomerPurchaseID from CustomerPurchase table
select  e.CustomerEventID
        , (select top 1 CustomerPurchaseID from @customerPurchase as p where p.CustomerEventID = e.CustomerEventID
                order by CustomerPurchaseID desc)
            as LastCustomerPurchaseID
from    @customerEvent as e

“ group”是装载名称