Reputation: 2398
I am writing an application which uses Hashicorp vault to store passwords and certificates. Right now I am using the default username/pass method to authenticate my client app.
When I try to add a secret I am getting { statusCode: 301, body: undefined }
when setting the apiVersion = v1
and { statusCode: 404, body: { errors: [] } }
when it is set to v2
.
Configuration:
let vaultOptions = {
apiVersion: 'v2',
endpoint: '0.0.0.0:8200'
};
const nodeVault = require('node-vault')(vaultOptions);
nodeVault.token = "secret token";
nodeVault.write('/secret/new', {"foo":"bar"}).then(
function (value: any) {
console.log(value);
})
.catch((err: any)=> {
console.log(err);
});
As the vault container is initialised by default I am not using the init
function.
I would like to know what am I missing here.
Upvotes: 1
Views: 1897
Reputation: 2398
The issue got fixed by adding /data
to the path and also the request data had to be inside an object {"data": .....}
.
nodeVault.write('/secret/data/new', {"data": {"foo":"bar"}}).then(
function (value: any) {
console.log(value);
})
.catch((err: any)=> {
console.log(err);
});
This was because the vault container was running on v2 engine
Upvotes: 6