element-hq / element-hq/synapse
Read config variables from files (e.g. docker secrets) and environment variables.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#14512](https://github.com/matrix-org/synapse/issues/14512).
---
Hi All, I've been setting up my own homeserver recently and I've come across an issue that many seem to have raised before me;
For the purpose of storing and backing up configuration it is not ideal to have secrets embedded within the config files themselves e.g. private keys, database passwords etc.
**Description:**
I would like to propose that support be added for reading particular config variables (and perhaps any config variable) from a file or environment variable by adding a suffix to the config option such as "_file" or "_env". Similar to how authelia handles the same problem (see [here](https://www.authelia.com/configuration/methods/secrets/))
**Suggested Implementation**
As for how this would be implemented, the easiest (albeit least efficient) approach I can think of would be to check all the attributes in a given config object (using something like `.vars()`) for a suffix such as `"_file"` or `"_env"` suffix (using something like python's string `endswith()` method)
Then whenever a match is found it could just attempt to read the file or environment variable into a new attribute with the suffix removed the contents of the file or environment variable.
The recursive nature of that approach is definitely slower but I figure since afaik it will only be happening at server startup it shouldn't be that bad as a first implementation. (The search could also be disabled by default as to not affect those who aren't going to use the feature.)
I'm be more than happy to implement this and make a PR myself. I just want to confirm that such a feature would be accepted.
Contributor guide
Assessment
This issue has not been assessed yet.