keyset

0.1.1 • Public • Published

keyset

Simple tool to help rotate keys in a suite of cooperating Heroku apps.

Tasks

Rekey a Server

Give the auth server in a particualar environment a new key.

$ keyset rekey test
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myweb-test              │ 2577d6a9ee4058597188c90f7a9f445b0e6b945cfff1a99e7b768768a19c54a5 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myauth-test             │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myapi-test              │ 2577d6a9ee4058597188c90f7a9f445b0e6b945cfff1a99e7b768768a19c54a5 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myapi-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myweb-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myauth-prod             │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘

Make sure the other API servers have that key. This step uses all the apps configured in the oc-api-<env> to decide which other apps need to be in sync with the auth server for that environment.

$ keyset sync      
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myweb-test              │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myauth-test             │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myapi-test              │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myapi-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myweb-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myauth-prod             │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘

Look to see if all the keys match.

$ keyset check         
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myweb-test              │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myauth-test             │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ test     │ myapi-test              │ b945cfff1a99e7b768768a19c54a52577d6a9ee4058597188c90f7a9f445b0e6 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘
┌──────────┬─────────────────────────┬──────────────────────────────────────────────────────────────────┐
│ Env      │ App                     │ Key                                                              │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myapi-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myweb-prod              │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
├──────────┼─────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ prod     │ myauth-prod             │ 808c81be713d7a7b65e8fc89e06c614a46d3476566bb59113622915137fa5bc9 │
└──────────┴─────────────────────────┴──────────────────────────────────────────────────────────────────┘

Setup

Config

$ npm install -g keyset

Config

Put a file like this at ~/.keyset.json, or it won't work.

{
  "secretKeyName": "HEROKU_CONFIG_NAME_FOR_SECRET_KEY",
  "envs": {
    "test": {
      "auth": "myauth-test",
      "apps": [
        "myauth-test",
        "myweb-test",
        "myapi-test"
      ]
    },
    "prod": {
      "auth": "myauth-prod",
      "apps": [
        "myauth-prod",
        "myweb-prod",
        "myapi-prod"
      ]
    }
  }
}

License

MIT.

Readme

Keywords

none

Package Sidebar

Install

npm i keyset

Weekly Downloads

0

Version

0.1.1

License

none

Last publish

Collaborators

  • timshadel