In my application we are making two calls from my app for getting secrets from Vault, as shown below:
Login to Vault : POST call to https::/v1/auth/approle/login -- It will take role_id and secret_id as payload and response will be client_token.
Fetch secrets : GET call to https::/v1/secret/data/abc/dev/xyz.json -- It will take headers as X-Vault-Token and X-Vault-Namespace and it will give you the response as below:
{ "request_id": "......", "lease_id": "", "renewable": false, "lease_duration": 0, "data": { "data": { "name": "ABC" }, "metadata": { "created_time": "...", "deletion_time": "", "destroyed": false, "version": 1 } }
Now I want to use Spring Cloud Vault Dependency to make things work through it. Please provide me the proper illustrations to make this work?
Assuming you are running spring boot and have a working Vault server configured for your app.
Add spring cloud vault maven dependency
Add vault configuration to bootstrap.yaml
If you run your app with spring profiles, like dev, it will be picked up and added to the vault path.
Now you should be able to inject secrets stored on the path
secret/data/abc/dev
with@Value("${<name-of-property>}