-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for file-based environment variables #19856
Comments
Maybe we don't need to mapping all the secrets into the ini file. But only some security related, I think they are not too much. If we support over 200 items via envs, it will become difficult when we want to deprecate them. Maybe these items:
|
Please see this. This new feature works, but it writes those secrets into the From what I can understand (please correct me if I'm wrong) that was not the intention? The secrets should be read directly from the secrets files into memory, without being written to config file. |
Configured secret env vars for mailer credentials to be loaded at pod runtime. We may want to write our credentials to an encrypted file so we can use the __FILE feature described here: go-gitea/gitea#19856. Or we may want to encrypt our secrets as described here: https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
Feature Description
In the new container-centric kubernetes-oriented world, storing secrets (or other related data) inside the ini settings file as plain text could be a major security threat and could lead to secrets end up being pushed to a git repository. And managing secrets as plain text in environment variables could also represent a security threat in setups that are using monitoring/reporting/orchestrating tools that log and store environment variables. That's why docker/Kubernetes and other tools offer the ability to manage secrets as separate artifacts in a secure way (on-disk encrypted, plain-text inside the container).
When using
docker secret
or other tools like Kubernetes, HashiCorp Vault, ... and were the secret is mounted as a file in/run/secrets/<SECRET_NAME>
there is a need for a mechanism to load those secrets from the mounted-plain-text-files to make them available to gitea.The proposal is that any settings in
app.ini
can be set or overridden with the content of a file by defining an environment variable of the form:GITEA__section_name__KEY_NAME__FILE
that points to a file (in case ofdocker secrets
it could point to/run/secrets/<SECRET_NAME>
).This technique could be used in
docker-compose.yml
as follows:As discussed with @zeripath in #19858 I will summarize the usability and security implications of the discussed implementations:
🟢 for positive point, 🔴 for negative point and empty when N/A or could be prevented
a. Implemented inside
gitea
: Load secrets from files to memory.b. Implemented inside
environment-to-ini
: Load secrets from file and populate ini file inside the container. Add support for file-based environment variables in environment-to-ini #19857🟠 : Managing the whole overlaid ini file (dedicated for secrets) with
docker secret
🟣 : I don't know if it could be a positive or negative point (in the short run) but the risk of breaking gitea is reduced and, for sure, for the long run it is better to implement it gitea-side.
[*]: When the secrets are separated from the general settings they could be managed by
docker secret
and mounted only when running the container.[**]: In all cases the secrets mounted as files will be present as plain text inside the container.
[***]: Having secrets as plain text in volumes could be a security risk but could be mitigated if using an encrypted filesystem and setting the correct file-permission for the volume directory to prevent unprivileged processes from accessing it.
Screenshots
No response
The text was updated successfully, but these errors were encountered: