mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-16 08:15:00 +00:00
feat(server): improve private key and cloud link flows
Add server private key generation from the dropdown, prevent deleting private keys that are still in use, and close cloud provider link modals after successful linking.
This commit is contained in:
1 parent
9b8aeb4758
commit
0217e2b0c0
14 files changed
+822
-252
No files matched your search
@@ -4,6 +4,7 @@ namespace App\Livewire\Security\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use App\Support\ValidationPatterns;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -22,8 +23,12 @@ class Show extends Component
|
||||
|
||||
public bool $isGitRelated = false;
|
||||
|
||||
public bool $isInUse = false;
|
||||
|
||||
public $public_key = 'Loading...';
|
||||
|
||||
public string $deleteDisabledReason = 'This private key is currently used by a server, application, or Git app and cannot be deleted.';
|
||||
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -74,16 +79,17 @@ class Show extends Component
|
||||
}
|
||||
}
|
||||
|
||||
public function mount()
|
||||
public function mount(?string $private_key_uuid = null)
|
||||
{
|
||||
try {
|
||||
$this->private_key = PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related', 'team_id'])->whereUuid(request()->private_key_uuid)->firstOrFail();
|
||||
$this->private_key = PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related', 'team_id'])->whereUuid($private_key_uuid ?? request()->private_key_uuid)->firstOrFail();
|
||||
|
||||
// Explicit authorization check - will throw 403 if not authorized
|
||||
$this->authorize('view', $this->private_key);
|
||||
|
||||
$this->syncData(false);
|
||||
} catch (\Illuminate\Auth\Access\AuthorizationException $e) {
|
||||
$this->isInUse = $this->private_key->isInUse();
|
||||
} catch (AuthorizationException $e) {
|
||||
abort(403, 'You do not have permission to view this private key.');
|
||||
} catch (\Throwable) {
|
||||
abort(404);
|
||||
@@ -102,7 +108,15 @@ class Show extends Component
|
||||
{
|
||||
try {
|
||||
$this->authorize('delete', $this->private_key);
|
||||
$this->private_key->safeDelete();
|
||||
|
||||
if ($this->private_key->isInUse()) {
|
||||
$this->isInUse = true;
|
||||
$this->dispatch('error', $this->deleteDisabledReason);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->private_key->delete();
|
||||
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
|
||||
|
||||
return redirectRoute($this, 'security.private-key.index');
|
||||
|
||||
Reference in new issue
Block a user