Validate APP_KEY (#13171)

* Validate APP_KEY
key:rotate command to rotate keys, only rotates validation data for now

* fixes, swapped encrypters, not saving new value to db, check that key exists first

* add confirmation

* Option to generate new key, re-encrypt data and then save it to .env
A lot more text to try to prevent disaster.  Print out both keys 1-2 times.
Fix bug in EnvHelper (when key is commented but not empty)

* fix style

* oops, good phpstan
This commit is contained in:
Tony Murray
2021-08-27 22:48:21 -05:00
committed by GitHub
parent 1ec694595e
commit 9b8b1b814a
6 changed files with 223 additions and 7 deletions

View File

@@ -90,8 +90,9 @@ class EnvHelper
$value = self::escapeValue($value);
if (strpos($content, "$key=") !== false) {
// only replace ones that aren't already set for safety and uncomment
if (preg_match("/^(#$key=$|$key=)/m", $content)) {
// enter this block if we have commented and empty or uncommented key
// only replace ones that aren't already set to a value for safety and uncomment
// escape $ in the replacement
$content = preg_replace("/#?$key=\n/", addcslashes("$key=$value\n", '$'), $content);
} else {