Skip to content
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

Setting backend passwords with docker compose secrets #3656

Merged

Conversation

aljora
Copy link
Contributor

@aljora aljora commented May 27, 2024

What type of PR is this?

  • feature

What this PR does / why we need it:

This change would allow administrators to share their secrets with the mealie container without needing to enter them through the environment variables, which could possibly expose them to other processes.

  • mealie/core/settings/settings.py has the addition of a secrets directory per the pydantic documentation
  • docs/docs/documentation/getting-started/installation/backend-config.md documents the use of the new feature

It was chosen to hard-code the path to avoid needed to process environment variables before the pydantic object was created. By default Docker places all secrets in files according to their names into a single directory. This supports the default use case but would need further effort to support other paths.

Which issue(s) this PR fixes:

Fixes #3606

Special notes for your reviewer:

Automated testing was considered but I did not want to inconvenience all other developers on this project by making them declare secrets in their dev containers or machines. Is there a need to create a CI workflow that uses a custom container to run tests?

Testing

The change was verified by running the production container with and without the secrets directory present. With the secrets directory, the content of the secret was evident in the logs showing that the information reached the backend successfully. Note that this PR does not address whether or not secrets are compromised by appearing in the logs. With the directory absent, the logs include a warning per the pydantic docs.

@boc-the-git
Copy link
Collaborator

@aljora this PR is in draft state, is that intentional?

@@ -236,7 +236,7 @@ def OPENAI_ENABLED(self) -> bool:
# Testing Config

TESTING: bool = False
model_config = SettingsConfigDict(arbitrary_types_allowed=True, extra="allow")
model_config = SettingsConfigDict(arbitrary_types_allowed=True, extra="allow", secrets_dir="/run/secrets")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't given thought to the full implications of this (or even looked at what SettingsConfigDict does), but I think we'd want this information reflected in the doco in some way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you.

@aljora
Copy link
Contributor Author

aljora commented May 28, 2024

@aljora this PR is in draft state, is that intentional?

Yes, I wanted to put this up there while I was confirming usage and writing documentation. I'll move it to the ready state.

@aljora aljora marked this pull request as ready for review May 28, 2024 21:29
@Kuchenpirat
Copy link
Collaborator

Hey, thanks for your work on this :)

Tested it and works for me 👍
Will leave it open for @boc-the-git to merge :)

@boc-the-git boc-the-git merged commit 445754c into mealie-recipes:mealie-next May 29, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting backend passwords with docker compose secrets
3 participants