0.0.2 • Published 5 years ago

hapi-azure-msi-vault-plugin v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

About hapi-azure-msi-vault-plugin

Tested successfully against Azure with Hapi v18.

Build Status

Install:

npm install hapi-azure-msi-vault-plugin --save

Prerequistes:

Setup an Azure Vault:

https://azure.microsoft.com/en-us/resources/samples/key-vault-node-getting-started/

Usage:

'use strict';

const Hapi = require('@hapi/hapi');

const server = new Hapi.Server({
    host: '0.0.0.0',
    port: process.env.PORT || 1337
});

const startup = async () => {
    await server.register([ 
        {
            plugin: require('hapi-azure-msi-vault-plugin'),
            options: {
               kvUri: 'https://<<YOUR VAULT HERE>>.vault.azure.net/'
            }
        }
    ]);
    await server.start();
};

startup().catch((err) => {
    throw err;
});

console.log(`${new Date()}: server running at ${server.info.uri}`);

How to fetch a secret:

server.app.vault('myAppSecret', 'myAppSecretVersion').then(secret => {
    console.log('secret: ', secret)
});