JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q30796F
  • License MIT

Just one key for all your application secrets!

Package Exports

  • masterkey

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (masterkey) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Problem

Usually a Node.js application has a configuration JSON that contains various secrets (for example, connection strings, app secrets, etc.) in clear text. Checking-in these secrets in a GIT (or any other) repository is a bad idea.

Solution

By using Microsoft Azure KeyVault & MasterKey CLI you can safely store your key/value without checking in the values in clear text in your GIT repository.

The core idea is to use a template like so:

{
  "server": {
    "not_a_secret": {
      "key1": "value1",
      "key2": "value2"
    },
    "secrets":{
      "masterkey_db_connection": "http://secret_key_name_url",
      "masterkey_facebook_client_id":"http://secret_facebook_client_id_url",
      "masterkey_facebook_client_secret":"http://secret_facebook_client_id_url"
    }
  }
}

Anything that is prefixed by masterkey should contain a valid Azure KeyVault URL. This URL will be replaced by the actual value at runtime. You can easily use this module with a configuration management package like config.

Detailed Setup

Step 1

Create your Key Vault in Azure

Step 2

Applications that use a key vault must authenticate by using a token from Azure Active Directory. To do this, the owner of the application must first register the application in their Azure Active Directory. At the end of registration, the application owner gets the following values:

  1. An Application ID (also known as a Client ID)
  2. Authentication Key (also known as the shared secret)

Get Started with KeyVault

Step 3

Create Access Policy for the Application Feed your Key Vault details

Documentation

  1. Azure Key Vault
  2. Step - by - Step
  3. setSecret