Skip to content

Commit

Permalink
Use OS/SAPI envvar for providing the password non-interactively
Browse files Browse the repository at this point in the history
  • Loading branch information
Iskren Hadzhinedev committed Mar 29, 2024
1 parent 02f7aa3 commit 6e65ab3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/Console/Commands/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,22 @@ public function handle(): int
protected function populateData(): array
{

/* Do not use laravel's `env()` because it reads the .env file.
* Instead explicitly require the variable to be set from the OS or the SAPI to avoid someone accidentally leaving it set in the .env file.
*/
$envPassword = getenv('IXP_SETUP_ADMIN_PASSWORD');
putenv('IXP_SETUP_ADMIN_PASSWORD'); // Unset the variable as soon as we read it to reduce the risk of it leaking.

$data = [
"asn" => $this->option('asn') ?? $this->ask('Enter the ASN of your IXP'),
"company_name" => $this->option('company-name') ?? $this->ask('Enter the name of your company'),
"infrastructure" => $this->option('infrastructure') ?? $this->ask('Enter the name of your primary infrastructure'),
"name" => $this->option('name') ?? $this->ask('Enter the full name(s) of the admin user'),
"username" => $this->option('username') ?? $this->ask('Enter the username of the admin user'),
"email" => $this->option('email') ?? $this->ask('Enter the email of the admin user'),
"password" => $this->secret('Enter the password of the admin user'),
"password" => $envPassword === false ? $this->secret('Enter the password of the admin user') : $envPassword,
];
if ($data['password'] !== $this->secret('Confirm the password of the admin user')) {
if ($envPassword === false && $data['password'] !== $this->secret('Confirm the password of the admin user')) {
$this->error('Passwords do not match. Exiting.');
exit(1);
}
Expand Down

0 comments on commit 6e65ab3

Please sign in to comment.