I'm trying to figure out the best approach to web application configuration. The goals are:
- Configurability. Force the configuration to be specified in deploy time. Make sure the configuration is kept separate from the code or deployable artifact.
- Security. Keep secrets from leaking from deployment environment.
- Simplicity. Make sure the solution is simple, and natural to the concept of OS process.
- Flexibility. Makes no assumptions about where the configuration is stored.
According to 12 factor app web application configuration is best provided in environment variables. It is simple and flexible but it looks like there are some security concerns related to this.
Another approach could be to pass all the configuration as command line arguments. This again is simple, flexible and natural to the OS but the whole configuration is then visible in host's process list. This might or might not be an issue (I'm no OS expert) but the solution is cumbersome at least.
A hybrid approach is taken by a popular framework Dropwizard where command line argument specifies config file location and the config is read from there. The thing is it brakes the flexibility constraint making assumptions about the location of my configuration (local file). It also makes my application implement file access which, while often easily achieved in most languages/frameworks/libraries, is not inherently simple.
I was thinking of another approach which would be to pass all the configuration in application's stdin
. Ultimately one could do cat my-config-file.yml | ./my-web-app
in case of locally stored file or even wget https://secure-config-provider/my-config-file.yml | ./my-web-app
. Piping seems simple and native to OS process. It seems extremely flexible as well as it separates the question of how is the config provided onto host OS.
The question is whether it conforms to the security constraint. Is it safe to assume that once piped content has been consumed it is permanently gone?
I wasn't able to google anyone trying this hence the question.