From 530558b0f82bd5509b374acb9c2628a846995ac3 Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Wed, 4 May 2022 19:23:01 -0400 Subject: [PATCH] Update deprecated JSON response creation and unnecessary middleware --- .../Admin/NodeAutoDeployController.php | 2 +- .../Nodes/SystemInformationController.php | 2 +- .../Nodes/NodeConfigurationController.php | 2 +- .../Servers/DatabaseController.php | 2 +- .../Api/Client/ApiKeyController.php | 2 +- .../Servers/ServerInstallController.php | 2 +- .../Controllers/Base/LocaleController.php | 2 +- app/Http/Kernel.php | 2 +- app/Http/Middleware/TrustProxies.php | 23 ------- composer.json | 1 - composer.lock | 60 +------------------ 11 files changed, 9 insertions(+), 91 deletions(-) delete mode 100644 app/Http/Middleware/TrustProxies.php diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php index a638a3f1d..79305a38b 100644 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php @@ -74,7 +74,7 @@ class NodeAutoDeployController extends Controller ], ['r_nodes' => 1]); } - return JsonResponse::create([ + return new JsonResponse([ 'node' => $node->id, 'token' => $key->identifier . $this->encrypter->decrypt($key->token), ]); diff --git a/app/Http/Controllers/Admin/Nodes/SystemInformationController.php b/app/Http/Controllers/Admin/Nodes/SystemInformationController.php index 476cea49c..954897a88 100644 --- a/app/Http/Controllers/Admin/Nodes/SystemInformationController.php +++ b/app/Http/Controllers/Admin/Nodes/SystemInformationController.php @@ -35,7 +35,7 @@ class SystemInformationController extends Controller { $data = $this->repository->setNode($node)->getSystemInformation(); - return JsonResponse::create([ + return new JsonResponse([ 'version' => $data['version'] ?? '', 'system' => [ 'type' => Str::title($data['os'] ?? 'Unknown'), diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php index 058f542b6..95ae70f3b 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php @@ -18,6 +18,6 @@ class NodeConfigurationController extends ApplicationApiController */ public function __invoke(GetNodeRequest $request, Node $node) { - return JsonResponse::create($node->getConfiguration()); + return new JsonResponse($node->getConfiguration()); } } diff --git a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php index 73f96737d..fc1756230 100644 --- a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php @@ -78,7 +78,7 @@ class DatabaseController extends ApplicationApiController { $this->databasePasswordService->handle($database); - return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT); + return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } /** diff --git a/app/Http/Controllers/Api/Client/ApiKeyController.php b/app/Http/Controllers/Api/Client/ApiKeyController.php index 34694d66c..b978cc8d4 100644 --- a/app/Http/Controllers/Api/Client/ApiKeyController.php +++ b/app/Http/Controllers/Api/Client/ApiKeyController.php @@ -102,6 +102,6 @@ class ApiKeyController extends ClientApiController throw new NotFoundHttpException(); } - return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT); + return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } } diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index be67ee53a..0e24f71be 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -45,7 +45,7 @@ class ServerInstallController extends Controller $server = $this->repository->getByUuid($uuid); $egg = $server->egg; - return JsonResponse::create([ + return new JsonResponse([ 'container_image' => $egg->copy_script_container, 'entrypoint' => $egg->copy_script_entry, 'script' => $egg->copy_script_install, diff --git a/app/Http/Controllers/Base/LocaleController.php b/app/Http/Controllers/Base/LocaleController.php index 3bb6fbfba..b6f2da4f5 100644 --- a/app/Http/Controllers/Base/LocaleController.php +++ b/app/Http/Controllers/Base/LocaleController.php @@ -31,7 +31,7 @@ class LocaleController extends Controller { $data = $this->translator->getLoader()->load($locale, str_replace('.', '/', $namespace)); - return JsonResponse::create($data, 200, [ + return new JsonResponse($data, 200, [ 'E-Tag' => md5(json_encode($data)), ]); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 3fac902c1..cf7b4a8d3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,11 +2,11 @@ namespace Pterodactyl\Http; +use Illuminate\Http\Middleware\TrustProxies; use Pterodactyl\Models\ApiKey; use Illuminate\Auth\Middleware\Authorize; use Illuminate\Auth\Middleware\Authenticate; use Pterodactyl\Http\Middleware\TrimStrings; -use Pterodactyl\Http\Middleware\TrustProxies; use Illuminate\Session\Middleware\StartSession; use Pterodactyl\Http\Middleware\EncryptCookies; use Pterodactyl\Http\Middleware\Api\IsValidJson; diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php deleted file mode 100644 index 3dff63eeb..000000000 --- a/app/Http/Middleware/TrustProxies.php +++ /dev/null @@ -1,23 +0,0 @@ -=5.4.0" - }, - "require-dev": { - "illuminate/http": "^5.0|^6.0|^7.0|^8.0|^9.0", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Fideloper\\Proxy\\TrustedProxyServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Fideloper\\Proxy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Chris Fidao", - "email": "fideloper@gmail.com" - } - ], - "description": "Set trusted proxies for Laravel", - "keywords": [ - "load balancing", - "proxy", - "trusted proxy" - ], - "support": { - "issues": "https://github.com/fideloper/TrustedProxy/issues", - "source": "https://github.com/fideloper/TrustedProxy/tree/4.4.1" - }, - "time": "2020-10-22T13:48:01+00:00" - }, { "name": "graham-campbell/result-type", "version": "v1.0.4",