Remove sensitive data from the tracked config files after running october:env

This commit is contained in:
Luke Towers 2018-04-06 01:18:07 -06:00
parent 8df92f4ba1
commit 0ac7f340be

View File

@ -24,6 +24,18 @@ class OctoberEnv extends Command
*/ */
protected $description = 'Creates .env file with default configuration values.'; protected $description = 'Creates .env file with default configuration values.';
/**
* @var array The env keys that need to have their original values removed from the config files
*/
protected $protectedKeys = [
'APP_KEY',
'DB_USERNAME',
'DB_PASSWORD',
'MAIL_USERNAME',
'MAIL_PASSWORD',
'REDIS_PASSWORD',
];
/** /**
* The current config cursor. * The current config cursor.
*/ */
@ -184,6 +196,11 @@ class OctoberEnv extends Command
$this->saveEnvSettings($envKey, $value); $this->saveEnvSettings($envKey, $value);
// Remove protected values from the config files
if (in_array($envKey, $this->protectedKeys) && !empty($value)) {
$value = "''";
}
return $this->isEnv($matches[0]) ? $matches[0] : "'$configKey' => env('$envKey', {$value}),"; return $this->isEnv($matches[0]) ? $matches[0] : "'$configKey' => env('$envKey', {$value}),";
}; };
} }