Allow one-time setup access via .env key for server use
This commit is contained in:
parent
a10908e227
commit
d541bbb9ad
|
|
@ -22,6 +22,14 @@ class Setup extends BaseController
|
|||
return $this->response->setStatusCode(404)->setBody('Setup is already completed and locked.');
|
||||
}
|
||||
|
||||
$keyFromEnv = trim((string) env('setup.dbToolsKey', ''));
|
||||
if ($keyFromEnv !== '') {
|
||||
$keyFromRequest = trim((string) ($this->request->getGet('key') ?? $this->request->getPost('key') ?? ''));
|
||||
if ($keyFromRequest !== '' && hash_equals($keyFromEnv, $keyFromRequest)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('auth')) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -77,6 +85,7 @@ class Setup extends BaseController
|
|||
'tables' => $tableRows,
|
||||
'msg' => $flash,
|
||||
'lock_file' => $this->lockFilePath(),
|
||||
'setup_key' => trim((string) env('setup.dbToolsKey', '')),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
<form method="post" action="<?= base_url('setup/db-tools/generate') ?>">
|
||||
<?= csrf_field() ?>
|
||||
<?php if (!empty($setup_key ?? '')) : ?>
|
||||
<input type="hidden" name="key" value="<?= esc($setup_key) ?>">
|
||||
<?php endif; ?>
|
||||
<div class="table-responsive" style="max-height:520px; overflow:auto; border:1px solid #eee;">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
|
|
@ -64,6 +67,9 @@
|
|||
|
||||
<form method="post" action="<?= base_url('setup/db-tools/complete') ?>" onsubmit="return confirm('This will lock setup page. Continue?');">
|
||||
<?= csrf_field() ?>
|
||||
<?php if (!empty($setup_key ?? '')) : ?>
|
||||
<input type="hidden" name="key" value="<?= esc($setup_key) ?>">
|
||||
<?php endif; ?>
|
||||
<button type="submit" class="btn btn-danger">Complete Setup and Lock Page</button>
|
||||
<p class="text-muted" style="margin-top:8px;">Lock file: <?= esc($lock_file ?? '') ?></p>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user