feathersjs-ecosystem / configuration

[MOVED] A plugin for configuring a Feathers application
https://github.com/feathersjs/feathers
MIT License
28 stars 15 forks source link

Configuration Management #26

Closed kc-dot-io closed 6 years ago

kc-dot-io commented 7 years ago

overview

as per issue #24 we want to make this repo more focused on configuration management as a whole. When it comes to reading configs, we'll look to node-config for this rather then re-invent that functionality. We should also build out the repo to have support for more complex production configuration management storage such as vault, consul and etc so that we can not only protect secrets but also eventually support service discovery.

goals


const feathers  = require('feathers');
const configuration  = require('feathers-configuration');
const etcd =  require('feathers-etcd')(['http://127.0.0.1:2379']);
const vault = require('feathers-vault')(['http://127.0.0.1:8200', process.env.VAULT_TOKEN]);

feathers()
  .configure(configuration()) // process.env.feathers + json files by default
  .configure(etcd())
  .configure(vault())

service discovery


// listen to a specific storage adapter directly
vault.on('create', function(key, value) {
  console.log(key, '=>', value); // /databases/mongo/production => mongodb://mongo.stack.local:27017
});

//listen across all storage adapters that support pub sub
configuration.on('create /databases/mongo/*', function(key, value) {
  console.log(key, '=>', value); // /databases/mongo/production => mongodb://mongo.stack.local:27017
});

vault.create({ 
  key:'/databases/mongo/production', 
  value: 'mongodb://mongo.stack.local.27107'
});

workflow

// 1. loads from process.env
// 2. loads from json files and merges
// 3. loads from etcd and merges
// 4. loads from vault and merges
// 5. listens to each storage
// 6. notifies of changes in storage
marshallswain commented 7 years ago

Should configurations be manageable via a public feathers service? (not very secure)

This can be made secure. One way would be to create a second, separate auth endpoint just for configuration tokens. Enabling IP-aware auth or multi-factor auth would help.

Should we bundle adapters or treat them as standalone plugins that extend feathers-configuration?

I would imagine we'd want them separate, just like the other adapters.

kc-dot-io commented 7 years ago

Cool, I think I can work with that. Typical best practice would be to put your configuration storage in a private subnet so there is no outside access, perhaps in a case where there is we can simply have before hook that validates based on IP or MFA like you suggested.

10-4. I think that looks best as well, however it might make it hard to centralize the service discovery events if you use multiple storage engines, unless I add a way to bind them at run time. I'll play with that idea a bit.

ekryski commented 7 years ago

Ya so far I'm really liking that direction. Not much to add after @marshallswain's comments.

daffl commented 6 years ago

Closing since it has been open for a while and I think it may now be out of scope of this little module. Happy to follow up some time in the future.