Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class App
/**
* @var string
*/
public const VERSION = '1.0.5';
public const VERSION = '1.0.6';

/**
* Set the base path of the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Flute\Core\Database\Entities\Server;
use Flute\Core\Rcon\RconService;
use Flute\Core\ServerQuery\ServerQueryService;
use Flute\Core\Services\DatabaseService;
use Illuminate\Support\Str;
use PDO;
use Throwable;
Expand Down Expand Up @@ -595,6 +596,7 @@ public function addDbConnection()
$connection->additional = json_encode($additional);
$connection->server = $this->server;
$connection->save();
DatabaseService::flushModesCache();

$this->dbConnections = DatabaseConnection::query()->where('server_id', $this->serverId)->fetchAll();
$this->flashMessage(__('admin-server.messages.connection_add_success'), 'success');
Expand Down Expand Up @@ -856,6 +858,7 @@ public function updateDbConnection()
$connection->dbname = $data['dbname'];
$connection->additional = json_encode($additional);
$connection->save();
DatabaseService::flushModesCache();

$this->dbConnections = DatabaseConnection::query()->where('server_id', $this->serverId)->fetchAll();
$this->flashMessage(__('admin-server.messages.connection_update_success'), 'success');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Flute\Admin\Packages\Server\Factories\ModDriverFactory;
use Flute\Core\Database\Entities\DatabaseConnection;
use Flute\Core\Database\Entities\Server;
use Flute\Core\Services\DatabaseService;

class AdminServersService
{
Expand Down Expand Up @@ -294,7 +295,7 @@ public function saveServer(?Server $server, array $data): Server
$server->setSettings($settings);
}

$server->save();
$server->save(false);

return $server;
}
Expand All @@ -311,6 +312,7 @@ public function deleteDbConnection(int $connectionId): void
}

$connection->delete();
DatabaseService::flushModesCache();
}

/**
Expand Down
49 changes: 0 additions & 49 deletions app/Core/Modules/Installer/Controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,6 @@ public function saveAndLaunch(FluteRequest $request): mixed
*/
private function guardInstallerAccess(FluteRequest $request): mixed
{
if (!$this->isInstallerRequestAllowed($request)) {
logs('installer')->warning('Denied installer access from non-local request.', [
'ip' => $request->getClientIp(),
'path' => $request->getPathInfo(),
]);

return response()->error(403, 'Installer access denied');
}

if ($request->isMethod('GET') || $request->isMethod('HEAD') || $request->isMethod('OPTIONS')) {
return null;
Comment on lines 734 to 735
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore remote-access guard for installer

When an uninstalled instance is reachable over the network, this now allows any remote client through the installer because GET/HEAD/OPTIONS return immediately and the removed local/setup-token check no longer runs. CSRF does not replace that guard here: a remote user can first load /install and receive the installer page with its CSRF token, then submit the setup forms. This regresses the previous restriction to local requests or FLUTE_INSTALLER_SETUP_TOKEN-authorized sessions.

Useful? React with 👍 / 👎.

}
Expand All @@ -756,46 +747,6 @@ private function guardInstallerAccess(FluteRequest $request): mixed
return null;
}

private function isInstallerRequestAllowed(FluteRequest $request): bool
{
if ($this->isLocalInstallerRequest($request)) {
return true;
}

if (session('installer.setup_authorized') === true) {
return true;
}

$expectedToken = (string) ( getenv('FLUTE_INSTALLER_SETUP_TOKEN') ?: config('installer.setup_token', '') );
if ($expectedToken === '') {
return false;
}

$providedToken = $request->input('setup_token') ?? $request->headers->get('X-Setup-Token');

if (!is_string($providedToken) || !hash_equals($expectedToken, $providedToken)) {
return false;
}

session()->set('installer.setup_authorized', true);

return true;
}

private function isLocalInstallerRequest(FluteRequest $request): bool
{
$clientIp = $request->getClientIp();
if (!in_array($clientIp, ['127.0.0.1', '::1'], true)) {
return false;
}

return (
!$request->headers->has('Forwarded')
&& !$request->headers->has('X-Forwarded-For')
&& !$request->headers->has('X-Real-IP')
);
}

protected function renderStep(int $id, array $extraData = [], bool $allowAdvance = true): mixed
{
$currentStep = $this->installerConfig->getCurrentStep();
Expand Down
4 changes: 4 additions & 0 deletions app/Core/Modules/Installer/Resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

@php
$title = __('install.title');
$currentStep = $currentStep ?? null;
$steps = $steps ?? [];
$totalSteps = $totalSteps ?? 0;
$stepData = $stepData ?? [];
@endphp

<head hx-head="append">
Expand Down
5 changes: 5 additions & 0 deletions app/Core/Services/DatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class DatabaseService

private static array $modesCache = [];

public static function flushModesCache(): void
{
self::$modesCache = [];
}

/**
* Retrieves server modes based on provided mods.
*
Expand Down
Loading