项目作者: visualjeff

项目描述 :
A Hapi v18 Azure MSI Vault plugin
高级语言: JavaScript
项目地址: git://github.com/visualjeff/hapi-azure-msi-vault-plugin.git
创建时间: 2019-06-10T03:47:29Z
项目社区:https://github.com/visualjeff/hapi-azure-msi-vault-plugin

开源协议:MIT License

下载


About hapi-azure-msi-vault-plugin

Tested successfully against Azure with Hapi v18.

Build Status

Install:

  1. 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:

  1. 'use strict';
  2. const Hapi = require('@hapi/hapi');
  3. const server = new Hapi.Server({
  4. host: '0.0.0.0',
  5. port: process.env.PORT || 1337
  6. });
  7. const startup = async () => {
  8. await server.register([
  9. {
  10. plugin: require('hapi-azure-msi-vault-plugin'),
  11. options: {
  12. kvUri: 'https://<<YOUR VAULT HERE>>.vault.azure.net/'
  13. }
  14. }
  15. ]);
  16. await server.start();
  17. };
  18. startup().catch((err) => {
  19. throw err;
  20. });
  21. console.log(`${new Date()}: server running at ${server.info.uri}`);

How to fetch a secret:

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