Skip to content

[FEATURE] Support loading sensitive values from files using _FILE suffixed environment variables #2310

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

Open
1 task done
enpaul opened this issue May 23, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request next minor

Comments

@enpaul
Copy link

enpaul commented May 23, 2025

What's needed and why?

I'd like to add support for loading sensitive values (such as the database URI, crowdsec API key, etc) from a file on disk specified by an environment variable, rather than directly from the environment. This will support Docker secrets as well as provide an alternative for users looking to avoid putting sensitive data directly into the app environment.

This feature would work by replacing some usages of os.getenv() with a function that does the below, for example trying to load a sensitive value from the environment variable FOO:

  1. Check if an environment variable named FOO_FILE exists
  2. If it does, attempt to open the value of that environment variable as a file path and read the contents
  3. If successful, return the contents of the file as the value of the secret
  4. If unsuccessful or if the environment variable FOO_FILE is not set, return the value of the environment variable FOO.

I've put together a prototype for this change in my fork:

Implementations ideas (optional)

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@enpaul enpaul added the enhancement New feature or request label May 23, 2025
@TheophileDiot
Copy link
Member

Hi @enpaul, this is a good idea. We'll have a look and let you know what we can do 😄

@TheophileDiot
Copy link
Member

Hi @enpaul, thanks for bringing this up!

Here's how it'll work:

BunkerWeb’s entrypoint scripts automatically detect and load secrets from /run/secrets, exporting each one directly as an environment variable inside the container. By default, secrets in Linux containers are mounted at /run/secrets/<secret_name>, which is precisely where BunkerWeb expects them—ensuring seamless and secure integration without additional configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next minor
Projects
None yet
Development

No branches or pull requests

2 participants