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

Add support for file-based docker secrets #1367

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nafur
Copy link

@nafur nafur commented Mar 18, 2024

The recommendation for passwords is to use secrets instead of writing them to compose files or environment variables.
This adds support for MYSQL_PASSWORD_FILE, MAIL_PASSWORD_FILE and SETUP_ADMIN_PASSWORD.

This is in line with https://docs.docker.com/compose/use-secrets/ and works like mariadb. Note that this PR only changes the php side. We might want to change the compose file as well like we do over here: froscon#5

@MyIgel
Copy link
Member

MyIgel commented Apr 6, 2024

Doing this just for one secret seems odd, wouldn't it be better to have some loader or something that does the file reading on the fly?

@MyIgel MyIgel added Type: Feature An idea for a new feature Status: Needs discussion Additional discussion/feedback is needed labels Apr 6, 2024
@nafur
Copy link
Author

nafur commented Apr 8, 2024

Doing this just for one secret seems odd, wouldn't it be better to have some loader or something that does the file reading on the fly?

You think of adding it for the mail password as well, and introducing a new utility that manages the precedence logic? Fine with me. Where should I put this utility?

@MyIgel
Copy link
Member

MyIgel commented Apr 22, 2024

Yes i mean adding some utilitarian wrapper for it :D
(Which should be located in the helpers.php file then)

Imho we could add it directly to the env function itself so that its universally useable for all secrets? (and there could also be a check that the file really exists before using it)

In addition it might be a good idea to also have a look how other projects handle the "magical" loading of files here, do you have an overview over that?

@nafur
Copy link
Author

nafur commented Apr 23, 2024

I moved the wrapper to helpers.php and check whether the file exists. I'm not sure where env even comes from.
I've just seen this file secrets in the mariadb container and it seems like a good idea.

Also, I've actually tested it now :-)

@MyIgel
Copy link
Member

MyIgel commented May 3, 2024

The env function is defined in vendor/illuminate/support/helpers.php and could be overwritten to directly use Env::get.
Speaking of tests: any code in he src directory must have unit tests ;)

@nafur
Copy link
Author

nafur commented May 16, 2024

I added a unit test. Given that we use this env() everywhere else, it seems more consistent to keep using it.

@nafur nafur changed the title Add support for MYSQL_PASSWORD_FILE Add support for file-based docker secrets May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs discussion Additional discussion/feedback is needed Type: Feature An idea for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants