I am trying to configure a docker set up of vault for dev purpose only. I am using com.bettercloud.vault-java-driver:3.1.0 library to access vault. But when I try to write to vault using above library, I get below exception
com.bettercloud.vault.VaultException: Expecting HTTP status 204 or 200, but instead receiving 400
Response body: {"errors":["missing client token"]}
at com.bettercloud.vault.api.Logical.write(Logical.java:162)
I also enabled vault logs and I see :
{"time":"2021-12-28T20:43:25.817670112Z","type":"request","auth":{"token_type":"default"},"request":{"id":"29bec0e9-994a-fcc6-8f01-b29c135ba4c8","operation":"read","mount_type":"kv","namespace":{"id":"root"},"path":"secret/v2/my-application/shared-dev/1/Adapters/TEST_CLIENT_AUTOMATION","remote_address":"172.25.0.5"},"error":"missing client token"}
I checked the write() method of com.bettercloud.vault.api.Logical class, it is already adding ‘X-Vault-Token’ token in the POST request, which is correctly configured.
My docker-compose looks like :
vault:
image: vault:1.8.7
container_name: vault
environment:
VAULT_ADDR: 'http://0.0.0.0:80'
VAULT_DEV_ROOT_TOKEN_ID: 420b2b0f-f2ed-3252-02dc-7ec511ae6183
VAULT_TOKEN: 420b2b0f-f2ed-3252-02dc-7ec511ae6183
VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:80
VAULT_API_ADDR: 'http://127.0.0.1:80'
ACCESS_KEY_ID: 420b2b0f-f2ed-3252-02dc-7ec511ae6183
cap_add:
- IPC_LOCK
ports:
- 8089:80
VaultConfig is configured to use above same token in the code.
Any idea, what wrong I am doing here, what more configuration needs to be done to get it working?