Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent way of managing config including secrets #2621

Closed
paulmelnikow opened this issue Jan 2, 2019 · 1 comment
Closed

Consistent way of managing config including secrets #2621

paulmelnikow opened this issue Jan 2, 2019 · 1 comment
Labels
blocker PRs and epics which block other work core Server, BaseService, GitHub auth, Shared helpers operations Hosting, monitoring, and reliability for the production badge servers self-hosting Discussion, problems, features, and documentation related to self-hosting Shields

Comments

@paulmelnikow
Copy link
Member

Currently we have three ways of loading secrets:

  1. In Heroku, other PaaS, and CI, from dynamic private/secret.json generated in a npm task at build time or runtime
  2. In Docker, from dynamic private/secret.json via secret.tpl.json generated by the Dockerfile at build time
  3. In the current / legacy production deploy, from checked-in private/secret.json generated in a deploy comment via the Makefile

I'd like to fold these three methods into a single method that covers on-premise, PaaS, and the current / legacy production deployment environment. To help solve #1848, this should not require a deploy commit.

See discussions: #2599 (comment) #2598 (comment)

Now that there is a config schema in lib/server.js, the server secrets could be folded into that. (However I want to make sure we do not accidentally leak credentials into log messages and error messages. So let's be careful that our config method doesn't do that.)

node-config is a great tool I've used in the past for cascading config. It lets you check in default configs which can be overridden by other checked-in configs for development, staging, production, or other environments (like self-hosting). You can create local config files which override those, and override anything else through environment variables. Here's a bit of explanation about how the cascade works.

Cascading config would replace the logic in lib/server-config.js, exposing a config object which could then be validated by Joi.

We could set NODE_CONFIG_ENV to values like shields-io-staging and shields-io-public which would then cause them to draw on additional config files which can be checked in and managed in this repo.

For the current / legacy production deployment, we still need a way to set NODE_CONFIG_ENV (#1806). The non-secret parts of the config can be checked into the main repo. For the secrets there are two options: (1) a checked-in local-shields-io-public.yml at deploy time, and (2) using additional environment variables.

There's a related proposal at #2577 (comment) about fetching the secrets from a secure token store for the legacy production deploy. However that proposal is adjacent to this one. That's about where the secrets are loaded at deploy time; this is about how they are loaded at runtime.

nconf looks like an alternative to node-config.

@paulmelnikow paulmelnikow added operations Hosting, monitoring, and reliability for the production badge servers self-hosting Discussion, problems, features, and documentation related to self-hosting Shields core Server, BaseService, GitHub auth, Shared helpers labels Jan 2, 2019
paulmelnikow added a commit that referenced this issue Jan 4, 2019
@paulmelnikow paulmelnikow added the blocker PRs and epics which block other work label Jan 4, 2019
paulmelnikow added a commit that referenced this issue Jan 6, 2019
This implements the configuration mechanism I described in #2621. The heavy lifting is delegated to [node-config](https://github.com/lorenwest/node-config) with a minor assist from [dotenv](https://github.com/motdotla/dotenv).

`private/secret.json` has been replaced with environment variables and/or `config/local.yml`. See `doc/server-secrets.md`.
@paulmelnikow
Copy link
Member Author

Closed via #2626.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker PRs and epics which block other work core Server, BaseService, GitHub auth, Shared helpers operations Hosting, monitoring, and reliability for the production badge servers self-hosting Discussion, problems, features, and documentation related to self-hosting Shields
Projects
None yet
Development

No branches or pull requests

1 participant