ptz0n / homebridge-verisure

 Platform plugin for Homebridge allowing to manage and control Verisure devices.
https://www.npmjs.com/package/homebridge-verisure
MIT License
66 stars 15 forks source link

Pass email and password as environment variables #47

Closed jodelamo closed 5 years ago

jodelamo commented 5 years ago

It would be nice if email, password and other sensitive values could be read from environment variables.

Something like:

$ VERISURE_EMAIL=john@doe.com VERISURE_PASSWORD=password123 homebridge

It would allow for checking in config.json files without sensitive key/values.

ptz0n commented 5 years ago

Thanks for reaching out Joacim.

I recommend that you never, ever share your config.json via version control or any file sharing protocol.

This file is the main place to store secrets for homebridge and installed plugins. I'm not currently aware of any plugin that pulls in secrets from the environment.

With this said, you should also create a separate Verisure user for homebridge with minimal permissions to suit the needs of your deployment.

If you still think this would be a great addition to the plugin, please share some details about your setup that lead your to this path.

jodelamo commented 5 years ago

I recommend that you never, ever share your config.json via version control or any file sharing protocol.

Yep. It's currently being gitignored.

It was mostly a convenience thing, inspired by this. I'm using this in a Docker context and wanted to read environment variables from an .env file. The end result would essentially be the same as putting values in config.json and gitignoring it.

Very "nice to have", but certainly not immediately useful to everyone.

ptz0n commented 5 years ago

This do makes sense to me when dealing with Docker containers, and I agree that this addition would be convenient in your case.

Looking at the Dyson plugin you referred to for inspiration; would it make sense to flip that conditional as proposed below?

const password = process.env.VERISURE_PASSWORD || config.password;
jodelamo commented 5 years ago

Yes. When providing an environment variable my assumption would be for it to take presedence.