问题描述
我正在使用
<dependency>
<groupId>org.springframework.vault</groupId>
<artifactId>spring-vault-core</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
我在Vault中的secret/data
上安装了我的秘密。我正在使用KV引擎版本2 。
此问题提到https://github.com/hashicorp/vault/issues/6254,如果我使用的是KV引擎版本2,我必须使用路径/ Metadata来获取LIST
-机密信息。在Vault-UI中找到。
示例:
> vault list secret/Metadata/TIM-tenant-information/data
Keys
tenant-3-oocut-ttezr
HTTP API无法使用完全相同的路径。我的代码:
@Autowired
private VaultOperations vaultOperations;
VaultVersionedkeyvalueOperations vaultVersionedkeyvalueOperations = this.vaultOperations.opsForVersionedkeyvalue("/secret/Metadata/");
List<String> files = vaultVersionedkeyvalueOperations.list("TIM-tenant-information/data/");
LOGGER.info("Files in path - {} are {}",path,files);
这将返回-Files in path - /secret/Metadata/TIM-tenant-information/data/ are []
我在做什么错了?
注意:我可以写到Vault。
示例代码:
private void writetoVault(String path,String fileName,Object obj) throws Exception {
if(StringUtils.isBlank(path) || StringUtils.isBlank(fileName))
throw new Exception("Path | Filename cannot be NULL or Empty");
LOGGER.debug("Writing {} to path {}",fileName);
try {
VaultVersionedkeyvalueOperations vaultVersionedkeyvalueOperations = this.vaultOperations.opsForVersionedkeyvalue(path + "/");
vaultVersionedkeyvalueOperations.put(fileName,obj);
} catch(Exception e) {
LOGGER.error("Error writing file {} to Path {},Reason: ",fileName,e);
throw e;
}
LOGGER.info("Success writing file[Name: {},Path: {}] to vault",path);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)