I want to create a wrapped token programmatically from my Spring Boot application in order to read/write key-value pairs to/from Hashicorp vault. I have gone through the documentation.
Currently I am able to create a token having a TTL, use limit and a policy, but I did not find any option to wrap the token. I am using the following code to create the token:
private VaultTokenResponse getDefaultToken() {
List<String> policies = Arrays.asList("default");
VaultTokenRequest tokenRequest = VaultTokenRequest.builder()
.ttl(10, TimeUnit.MINUTES)
.numUses(10)
.policies(policies)
.renewable(true)
.build();
return VaultConfig.vaultTemplate.opsForToken().create(tokenRequest);
}
You can try to use VaultWrappingOperations on the token once you have created it. Something like