• Stars
    star
    431
  • Rank 100,866 (Top 2 %)
  • Language
    JavaScript
  • Created over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Client for HashiCorp's Vault

node-vault

Build Status Coverage Status Download Status test Dependency Status Open Collective backers and sponsors

A client for the HTTP API of HashiCorp's Vault written for Node.js.

install

make sure to use node.js version >= 6

npm install node-vault

test

Run tests inside docker to do also nice integration testing:

docker-compose up --force-recreate test

This will create containers for vault, postgres and running the tests inside docker.

usage

init and unseal

var options = {
  apiVersion: 'v1', // default
  endpoint: 'http://127.0.0.1:8200', // default
  token: '1234' // optional client token; can be fetched after valid initialization of the server
};

// get new instance of the client
var vault = require("node-vault")(options);

// init vault server
vault.init({ secret_shares: 1, secret_threshold: 1 })
.then( (result) => {
  var keys = result.keys;
  // set token for all following requests
  vault.token = result.root_token;
  // unseal vault server
  return vault.unseal({ secret_shares: 1, key: keys[0] })
})
.catch(console.error);

write, read and delete secrets

vault.write('secret/hello', { value: 'world', lease: '1s' })
.then( () => vault.read('secret/hello'))
.then( () => vault.delete('secret/hello'))
.catch(console.error);

docs

Just generate docco docs via npm run docs.

examples

Please have a look at the examples and the generated feature list to see what is already implemented.

Instead of installing all the dependencies like vault itself, postgres and other stuff you can use docker and docker-compose to link and run multiple docker containers with all of its dependencies.

git clone [email protected]:kr1sp1n/node-vault.git
cd node-vault
docker-compose up vault

Now you can run the examples from another terminal window.

First of all you should initialize and unseal the vault:

node example/init.js

You should see root_token: followed by a long key in the response. Please copy that long key and export it as environment variable:

export VAULT_TOKEN=<insert long key here>

Now you are able to run all of the other examples:

node example/policies.js

Connecting to vault through a bastion host

To connect to a vault server in a private network with a bastion host, you'll need to first open a connection:

ssh -D <socks4Port> bastion.example.com
const SocksProxyAgent = require('socks-proxy-agent');
const agent = new SocksProxyAgent(`socks://127.0.0.1:${socks4Port}`, true);
const options = {
  apiVersion: 'v1',
  rpOptions: {
    agent,
  },
};

const vault = require('node-vault')(options);

Backers

More Repositories

1

awesome-gemini

A collection of awesome things regarding the gemini protocol ecosystem.
1,018
star
2

bvg-api

An inofficial API for the BVG (Berlin Public Transportation Services) written for node.js
JavaScript
45
star
3

gemini-pandoc-lua-filter

Pandoc Lua filter to transform HTML to text/gemini.
Lua
19
star
4

zanox

One Ruby gem to rule the zanox API
Ruby
16
star
5

winston-amqp

An AMQP Transport for winston
JavaScript
11
star
6

graphql-openfaas-demo

GraphQL Gateway to OpenFAAS functions
JavaScript
7
star
7

copypasta

Just a simple pastebin.com clone as a web service
JavaScript
4
star
8

explaintag

A twitter bot explaining socially validated hashtags
JavaScript
3
star
9

vault-webui

WIP - web UI for Hashicorp's vault
JavaScript
3
star
10

kvit

Key-value store CLI based on https://github.com/noffle/twitter-kv
JavaScript
3
star
11

devon

deno as cross-plattform shell
JavaScript
3
star
12

deno-preact-ssr-example

server-side rendering with deno
JavaScript
2
star
13

hotcoffee

Simple RESTful webserver written for Node.js
CoffeeScript
2
star
14

dashboard

An event-driven P2P Dashboard using the pusher.com API as event transport
JavaScript
2
star
15

winston-cube

A Cube Transport for winston
JavaScript
2
star
16

koronacloud

Javascript client for the KORONA.pos Cloud API
JavaScript
2
star
17

alpine-neovim

my neovim inside docker
2
star
18

awesome-tcl-tk

Awesome list of Tcl/Tk resources
2
star
19

cavern

A RESTful wrapper around Hashicorp's vault
JavaScript
2
star
20

licht

print n times a symbol in C
C
1
star
21

vault-repo-example

dev workflow with vault
Shell
1
star
22

docker-dotfiles

My dotfiles as data-only docker image
Vim Script
1
star
23

express-casl-rbac-example

JavaScript
1
star
24

noswearbot

A very simple google wave bot that censors a list of bad words.
Python
1
star
25

hello-pixilang

Learning Pixilang
1
star
26

slides

slides i did for different presentations
1
star
27

zapper

Sinatra test application for showing usage of zanox Gem and zanox Connect.
1
star
28

petri-prototype

Petri net player and editor for the web
JavaScript
1
star
29

slidder

Create a slide show made of tweets.
Ruby
1
star
30

crowdcontrol

Sinatra app to broadcast OSC over LAN to control the environment of a place by the crowd
Ruby
1
star
31

api_client_php

A PHP client for the zanox API
PHP
1
star
32

database-as-program

Inspired by https://www.tcl.tk/community/tcl2004/Papers/D.RichardHipp/drh.html
Shell
1
star
33

service-pipeline

Pipelines as a service
JavaScript
1
star
34

docker-vault

Run vault in Linux container
Shell
1
star
35

teatteri

throw images on walls
JavaScript
1
star
36

putki

Headless Continuous Integration Server
CoffeeScript
1
star
37

jesusmatrix

Calculate the value of words -> http://jesusmatrix.de.to
JavaScript
1
star