Skip to content

Commit 6e65ab3

Browse files
author
Iskren Hadzhinedev
committed
Use OS/SAPI envvar for providing the password non-interactively
1 parent 02f7aa3 commit 6e65ab3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: app/Console/Commands/SetupWizard.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,22 @@ public function handle(): int
170170
protected function populateData(): array
171171
{
172172

173+
/* Do not use laravel's `env()` because it reads the .env file.
174+
* 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.
175+
*/
176+
$envPassword = getenv('IXP_SETUP_ADMIN_PASSWORD');
177+
putenv('IXP_SETUP_ADMIN_PASSWORD'); // Unset the variable as soon as we read it to reduce the risk of it leaking.
178+
173179
$data = [
174180
"asn" => $this->option('asn') ?? $this->ask('Enter the ASN of your IXP'),
175181
"company_name" => $this->option('company-name') ?? $this->ask('Enter the name of your company'),
176182
"infrastructure" => $this->option('infrastructure') ?? $this->ask('Enter the name of your primary infrastructure'),
177183
"name" => $this->option('name') ?? $this->ask('Enter the full name(s) of the admin user'),
178184
"username" => $this->option('username') ?? $this->ask('Enter the username of the admin user'),
179185
"email" => $this->option('email') ?? $this->ask('Enter the email of the admin user'),
180-
"password" => $this->secret('Enter the password of the admin user'),
186+
"password" => $envPassword === false ? $this->secret('Enter the password of the admin user') : $envPassword,
181187
];
182-
if ($data['password'] !== $this->secret('Confirm the password of the admin user')) {
188+
if ($envPassword === false && $data['password'] !== $this->secret('Confirm the password of the admin user')) {
183189
$this->error('Passwords do not match. Exiting.');
184190
exit(1);
185191
}

0 commit comments

Comments
 (0)