diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php
new file mode 100644
index 000000000..be6301c31
--- /dev/null
+++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php
@@ -0,0 +1,88 @@
+keyCreationService = $keyCreationService;
+ $this->repository = $repository;
+ $this->encrypter = $encrypter;
+ }
+
+ /**
+ * Generates a new API key for the logged in user with only permission to read
+ * nodes, and returns that as the deployment key for a node.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Pterodactyl\Models\Node $node
+ * @return \Illuminate\Http\JsonResponse
+ *
+ * @throws \Pterodactyl\Exceptions\Model\DataValidationException
+ */
+ public function __invoke(Request $request, Node $node)
+ {
+ /** @var \Pterodactyl\Models\ApiKey|null $key */
+ $key = $this->repository->getApplicationKeys($request->user())
+ ->filter(function (ApiKey $key) {
+ foreach ($key->getAttributes() as $permission => $value) {
+ if ($permission === 'r_nodes' && $value === 1) {
+ return true;
+ }
+ }
+
+ return false;
+ })
+ ->first();
+
+ // We couldn't find a key that exists for this user with only permission for
+ // reading nodes. Go ahead and create it now.
+ if (! $key) {
+ $key = $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([
+ 'user_id' => $request->user()->id,
+ 'memo' => 'Automatically generated node deployment key.',
+ 'allowed_ips' => [],
+ ], ['r_nodes' => 1]);
+ }
+
+ return JsonResponse::create([
+ 'node' => $node->id,
+ 'token' => $key->identifier . $this->encrypter->decrypt($key->token),
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php
index a7d710a10..d482c47ae 100644
--- a/app/Http/Controllers/Admin/NodesController.php
+++ b/app/Http/Controllers/Admin/NodesController.php
@@ -9,7 +9,6 @@
namespace Pterodactyl\Http\Controllers\Admin;
-use Cake\Chronos\Chronos;
use Illuminate\Http\Request;
use Pterodactyl\Models\Node;
use Illuminate\Http\Response;
@@ -300,18 +299,4 @@ class NodesController extends Controller
return redirect()->route('admin.nodes');
}
-
- /**
- * Returns the configuration token to auto-deploy a node.
- *
- * @param \Pterodactyl\Models\Node $node
- * @return \Illuminate\Http\JsonResponse
- */
- public function setToken(Node $node)
- {
- $token = bin2hex(random_bytes(16));
- $this->cache->put('Node:Configuration:' . $token, $node->id, Chronos::now()->addMinutes(5));
-
- return response()->json(['token' => $token]);
- }
}
diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php
new file mode 100644
index 000000000..fc0c35f75
--- /dev/null
+++ b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php
@@ -0,0 +1,25 @@
+getConfiguration());
+ }
+}
diff --git a/resources/views/admin/nodes/view/configuration.blade.php b/resources/views/admin/nodes/view/configuration.blade.php
index f1c7b0f34..778c6a057 100644
--- a/resources/views/admin/nodes/view/configuration.blade.php
+++ b/resources/views/admin/nodes/view/configuration.blade.php
@@ -71,8 +71,7 @@
swal({
type: 'success',
title: 'Token created.',
- text: 'Your token will expire in 5 minutes.
' +
- '
To auto-configure your node run the following command:npm run configure -- --panel-url {{ config('app.url') }} --token ' + data.token + '
To auto-configure your node run the following command:cd /srv/wings && ./wings configure --panel-url {{ config('app.url') }} --token ' + data.token + ' --node ' + data.node + '{{ config('app.debug') ? ' --allow-insecure' : '' }}