feat: interactive env:encrypt & env:decrypt#53081
Merged
taylorotwell merged 7 commits intoOct 10, 2024
Merged
Conversation
crynobone
reviewed
Oct 9, 2024
| $key = $this->option('key') ?: Env::get('LARAVEL_ENV_ENCRYPTION_KEY'); | ||
|
|
||
| if (! $key) { | ||
| $key = $this->ask('Decryption key'); |
Member
There was a problem hiding this comment.
Maybe better to use https://laravel.com/docs/11.x/prompts#password
Contributor
Author
There was a problem hiding this comment.
Great idea, have changed this now
crynobone
reviewed
Oct 9, 2024
| {--prune : Delete the original environment file} | ||
| {--force : Overwrite the existing encrypted environment file}'; | ||
| {--force : Overwrite the existing encrypted environment file} | ||
| {--interactive : Prompt the encryption key}'; |
Member
There was a problem hiding this comment.
Should just use $this->input->isInteractive() instead of adding new option. https://github.com/symfony/console/blob/7.1/Input/InputInterface.php#L125
Contributor
Author
There was a problem hiding this comment.
Did not know the existence of this one. Have used that instead. However, I've then also added a select prompt since I do want the interactive user to be able to opt for a generated key instead of having to provide one. This will however change the current interactive command line experience. Not sure if that would be a problem.
timacdonald
pushed a commit
to timacdonald/framework
that referenced
this pull request
Oct 15, 2024
* feat: add interactive mode for env:encrypt & env:decrypt * style: remove whitespace changes * feat: use password prompt & isInteractive() * style: added end of line comma in array * test: change/provide tests for interactive mode * style: remove empty line * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
env:encryptand especiallyenv:decrypt, it was bugging me that I had to provide the encryption key in the command line and it therefore ended up in my command line history. I did not want to use the LARAVEL_ENV_ENCRYPTION_KEY environment variable as I do not want the encryption key to be stored on the development machine.Hereby a PR to add a simple interactive mode for
env:descryptthat wouldask()for the decryption key and prevent it from ending up in history. Forenv:encryptI added an--interactiveoption to not break the current behavior of automatically generating an encryption key.