Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor ShowPrivateKey component and add validation for owned private key

Andras Bacsaid938a6ce8fe7
diff --git a/app/Livewire/Server/ShowPrivateKey.php b/app/Livewire/Server/ShowPrivateKey.php
index b76c0a405b..cc77fd6114 100644
--- a/app/Livewire/Server/ShowPrivateKey.php
+++ b/app/Livewire/Server/ShowPrivateKey.php
@@ -2,6 +2,7 @@
namespace App\Livewire\Server;
+use App\Models\PrivateKey;
use App\Models\Server;
use Livewire\Component;
@@ -20,6 +21,13 @@ class ShowPrivateKey extends Component
public function setPrivateKey($privateKeyId)
{
+ $ownedPrivateKey = PrivateKey::ownedByCurrentTeam()->find($privateKeyId);
+ if (is_null($ownedPrivateKey)) {
+ $this->dispatch('error', 'You are not allowed to use this private key.');
+
+ return;
+ }
+
$originalPrivateKeyId = $this->server->getOriginal('private_key_id');
try {
$this->server->update(['private_key_id' => $privateKeyId]);