Hi team,
As we work on adding one-click, zero-config deployment options to Mathesar, we need to address how we manage the SECRET_KEY environment variable. We do not want users to have to set ENV vars manually. That level of technical knowledge defeats the purpose of one-click installation entirely.
There are a couple of directions I can see for how we can avoid users needing to set this manually:
Set a default (unsafe, bad) key
We could define a default SECRET_KEY in the various configurations for one-click environments. This would allow the deployment to succeed out of the box. Then, we could warn users post-install that they should “harden” their installation by replacing the key and restarting Mathesar on whatever platform they're using. This gets Mathesar working right away without making people mess with environment variables, but it at best defers the problem and at worst creates a bunch of insecure Mathesar instances in the wild.
Auto-Generate and Persist a Key
We could auto-generate a secure key at first launch and persist it somewhere: either to the filesystem (e.g., a config file in the container or mounted volume) or to the database (seems weird, idk). This would essentially be a "more secure" default as opposed to the first solution, and the user could still override it by setting the ENV var on their own later on.
I'm curious what people think about this problem and if you see any other solutions. Or, if you see any flaws with the solutions I've proposed that I've missed.
Thanks,
Zack
If that's not possible, it's not really one-click at all