-
Notifications
You must be signed in to change notification settings - Fork 60
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 to for Secrets to be generated before generating secrets #226
Conversation
Added update in the docs to reflect the improvement. |
@DonRichards I don't think this will work for randomly generated secrets. The other thing USE_SECRETS does is include the file docker-compose.secrets.yml. As I understand it, without this file it won't use secrets at all and must use hard coded values in the containers. This would mean that if USE_SECRETS=false it would never use the randomly generated secrets in secrets/live. |
@joshdentremont Feel free to test this now. I think it covers everything we talked about. |
@DonRichards sha1sum is not installed on macOS. When I run make local with USE_SECRETS=false I get a bunch of warnings like this: Also, I think we might want to change the name of the USE_SECRETS variable since it no longer does the same thing as it used to and this could confuse people. Maybe we should rename it to USE_CUSTOM_SECRETS or something like that? |
OK, I'll make the change. |
@joshdentremont Give this a try. I switched it to MD5 which is more common and a default for linux mac. |
Same problem |
Looks like Mac has a program called md5 that does the same thing |
I added a OS check since in linux the command is md5sum and OSX is just md5. I switched the Linux version back to sha1sum and OSX to MD5. Also added a bypass for anyone that wants a CICD script to generate new secrets by passing yes into the script directly |
OK, @joshdentremont it's ready. |
It's telling me I'm using default secrets when I'm not. I think this is because of the following I think what you want for MD5 is this (print $4 instead of print $1): |
Yeah, made an assumption there. OK. I switched MACs to the failsafe so that I'm not duplicated more code or spending too much time on this. So basically it will compare the cat output for either file. Lets give this one a try. |
Tested with USE_SECRETS=false and it created the randomly generated secrets but does not use them. I wonder if we should stop if from generating them when it's set to false? This probably doesn't matter but it has confused me in the past. I also misunderstood how you had set this up so you can ignore my earlier comments about renaming USE_SECRETS. I thought you had made it so USE_SECRETS=false was the way to use randomly generated secrets. Trying with USE_SECRETS=true and got this issue: I think you can just drop the -I because ls will not list hidden files anyway unless you give it the -a option. I removed it and things seem to run as intended Another issue I see is that I changed only the drupal account password and it's still telling me I am using the default. I don't know if there's a check for individual ones or if it just outputs all the secrets when any of them are using the defaults. |
Setting Setting Setting Setting I would say this is all working except for the |
@joshdentremont I can remove the "i" part of that command. As for changing the admin password, if you're using the |
@joshdentremont Ready to check |
I'll give that a try and push as soon as I can. |
@joshdentremont OK, ready. |
@DonRichards Looks good now. |
Ready for testing |
This worked for me, to not stop on existing secrets being there. ❤️ |
To enable using secrets after run `make local` or `make up`, set | ||
`USE_SECRETS=true` in your .env file. When you run `make docker-compose.yml`, a | ||
large block of `secrets` will be added at the top of your `docker-compose.yml` | ||
file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to also mention that they should be sure to set
to the value of DRUPAL_DEFAULT_SALT
to $settings['hash_salt'] in codebase/web/sites/default/settings.php and the value of DRUPAL_DEFAULT_DB_PASSWORD
to the value $databases['default']['default']['password']
in the same file (it's actually in the file twice??)
Or maybe we should use the file path option instead of parsing it into the file? $settings['hash_salt'] = file_get_contents('/home/example/salt.txt');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also will a make up update passwords if they are created after a make local
or make up
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see $databases['default']['default']['password'] once in my install.
I just pushed a warning to the user to manually update their settings.php file when it notices a difference between the secrets/live/DRUPAL_DEFAULT_SALT
and web/sites/default/settings.php
file. I felt like it might take too long to try to automatically do this for the user and restart their container because this script is running on the local and we'd need to account for Mac command discrepancies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it was my older version had some extra things in there
I also think it might be worth at somepoint just creating secrets or using existing ones going forward, and not, not having them. ie "USE_SECRETS" goes away except maybe as a legacy option for existing systems? (expert option?) |
The last test for the missing secret prompt didn't work when I tested this morning:
I should also note that the requests for |
@misilot @seth-shaw-unlv This is ready to test again. |
In the section "Testing auto generate secrets with USE_SECRETS is set to true" it indicates that after selecting "yes" one should run "make up" again. However, the script simply continues running the "make demo". Is that the expected behavior, @DonRichards? |
No. I don't believe so. Let me double-check now |
@seth-shaw-unlv Sorry, yes, that's correct—this way new people can build right away with as few steps as possible. But if a person is only copying files over, I assume it's for a purpose (to add their passwords to the files). |
Oh, and it should ask the user if they want to exit when they opt for copying the defaults over. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Purpose of this:
In a Slack chat it was brought up that users may be running default secrets and not know it and secrets are generated on every build. In fact there was several small improvements that were needed.
Currently the build process will always generate secrets even when USE_SECRETS is set to true . This adds a simple check then prompt that prevents the code from running the generate script (re)populating the /secrets/live* directory on every make up/down.
For the sake of keeping the description simple I'm going to use the terms
make local
,make up
ormake demo
interchangeably as a reference to the make build process. It should not matter which of these to use to build ISLE. The tests will not only test the functionality but the ability to bypass/skip a function or not do anything at all. If USE_SECRETS is set to false or all the secrets exist in the secrets/live/ directory, this will not prompt the user for input.3 scenarios to test for
Test USE_SECRETS set to either true or false for these 3 scenarios. But USE_SECRETS will always result in secrets/live/ being repopulated with new secrets every time a make build process is ran.
Also because this is part of the build process, you will need to run
make clean
between comparing current behavior vs new and different scenarios.To test that this doesn't break existing setups
make up
command.You will see a message informing you if you're using default values, otherwise no message.
Run
make clean
to reset. Copy sample.env and modify the .env file to USE_SECRETS=false.To test when USE_SECRETS is set to false
make local
This should automatically generate custom secrets.
To check this worked
Check to see if the directory /secrets/live is populated with secrets, most of them are NOT set to "password"
Run
make clean
to reset. Copy sample.env and modify the .env file to USE_SECRETS=true to disable new secret generation as the default action.Testing that answering No to prompt results in no changes with USE_SECRETS is set to true
When the script determines there's an issue, the user is prompted to either generate or copy secrets. This first check verifies nothing happens when n or N is applied to the prompts.
make local
It should exit completely.
To check this worked
Check to see if the directory /secrets/live is still empty.
Testing auto generate secrets with USE_SECRETS is set to true
make demo
This should automatically generate custom secrets just like the last test.
make up
againThere should be no message/warnings.
To check this worked
Check to see if the directory /secrets/live is populated with secrets, most of them are NOT set to "password"
Testing copying template secrets with USE_SECRETS is set to true
Run
make clean
to reset. Copy sample.env and modify the .env file to USE_SECRETS=true to disable new secret generation as the default action.make local
This will copy the template/ files to the live/ directory. But it's advised to make changes to these files before proceeding. The messages should be clear (if not please suggest something). This also exits not only the bash script but also the MAKEFILE. This was does intentionally.
This will check the config and output a message at both the beginning and the end of the build. This message will inform the user which secrets are using default values with information on where to go for further information.
make up
again and the message should come up again last to inform the user they are using default/insecure secrets.Testing with missing secrets while USE_SECRETS is set to true
This will copy (not generate) the missing secrets from the template directory.
make up
again and message is set back to the warning message when a default value is detected.Note: This points to where the documentation should be but that doesn't exist yet.
Sorry for the really really long description.