100 lines
4.0 KiB
PHP
100 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Servers;
|
|
|
|
use App\Models\Server;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
#[Layout('layouts.app')]
|
|
#[Title('Server-Details — Clusev')]
|
|
class Show extends Component
|
|
{
|
|
/** Route-model-bound by uuid (R11). */
|
|
public Server $server;
|
|
|
|
/**
|
|
* Mock data below. The SSH layer (phpseclib exec + SFTP) replaces these later;
|
|
* shapes mirror what SshClient/FleetService will return.
|
|
*/
|
|
public array $volumes = [];
|
|
|
|
public array $interfaces = [];
|
|
|
|
public array $hardening = [];
|
|
|
|
public array $sshKeys = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->volumes = [
|
|
['mount' => '/', 'fs' => 'ext4', 'size' => '40 GB', 'used' => 62],
|
|
['mount' => '/var', 'fs' => 'ext4', 'size' => '80 GB', 'used' => 78],
|
|
['mount' => '/var/log', 'fs' => 'ext4', 'size' => '10 GB', 'used' => 41],
|
|
['mount' => '/boot', 'fs' => 'ext2', 'size' => '512 MB', 'used' => 23],
|
|
['mount' => '/srv/data', 'fs' => 'xfs', 'size' => '500 GB', 'used' => 91],
|
|
];
|
|
|
|
$this->interfaces = [
|
|
['name' => 'eth0', 'ip' => '10.10.90.136', 'mac' => '52:54:00:a1:9c:3e', 'rx' => '1.42 TB', 'tx' => '318 GB'],
|
|
['name' => 'eth1', 'ip' => '10.20.0.4', 'mac' => '52:54:00:b7:11:02', 'rx' => '94.1 GB', 'tx' => '57.8 GB'],
|
|
['name' => 'wg0', 'ip' => '10.99.0.1', 'mac' => '—', 'rx' => '12.3 GB', 'tx' => '8.91 GB'],
|
|
['name' => 'lo', 'ip' => '127.0.0.1', 'mac' => '—', 'rx' => '4.10 GB', 'tx' => '4.10 GB'],
|
|
];
|
|
|
|
$this->hardening = [
|
|
['label' => 'SSH-Root-Login deaktiviert', 'detail' => 'PermitRootLogin no', 'status' => 'online'],
|
|
['label' => 'fail2ban aktiv', 'detail' => 'fail2ban.service · läuft', 'status' => 'online'],
|
|
['label' => 'UFW aktiv', 'detail' => 'ufw status · inactive', 'status' => 'offline'],
|
|
['label' => 'Automatische Updates', 'detail' => 'unattended-upgrades · läuft', 'status' => 'online'],
|
|
];
|
|
|
|
$this->sshKeys = [
|
|
['comment' => 'admin@clusev', 'type' => 'ed25519', 'fingerprint' => 'SHA256:7Xq2c1f9Hn0pL3kVtY8zR4mB6dWqUe2sJ1aKxN0oPq'],
|
|
['comment' => 'deploy@ci', 'type' => 'ed25519', 'fingerprint' => 'SHA256:9Az4Db8Fc2Ge6Hj0kL3Mn7Op1Qr5St9Uv3Wx7Yz1A'],
|
|
['comment' => 'backup@offsite', 'type' => 'rsa-4096', 'fingerprint' => 'SHA256:Kp3Lm9Nq2Rs5Tv8Wx1Yz4Ab7Cd0Ef3Gh6Ij9Kl2Mn'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Revoke an SSH key (R5): opens the confirm modal, which writes the
|
|
* AuditEvent and re-dispatches `keyRemoved`. SSH layer removal lands later.
|
|
*/
|
|
public function confirmKeyRemoval(string $fingerprint, string $comment): void
|
|
{
|
|
$this->dispatch('openModal',
|
|
component: 'modals.confirm-action',
|
|
arguments: [
|
|
'heading' => 'SSH-Schlüssel entfernen',
|
|
'body' => "Der Schlüssel „{$comment}“ verliert den Zugang zu {$this->server->name}.",
|
|
'confirmLabel' => 'Entfernen',
|
|
'danger' => true,
|
|
'icon' => 'trash',
|
|
'auditAction' => 'ssh_key.remove',
|
|
'auditTarget' => "{$comment} · {$this->server->name}",
|
|
'serverId' => $this->server->id,
|
|
'event' => 'keyRemoved',
|
|
'params' => ['fingerprint' => $fingerprint],
|
|
'notify' => "Schlüssel „{$comment}“ entfernt.",
|
|
],
|
|
);
|
|
}
|
|
|
|
/** Applies the confirmed key removal (mock until SSH layer lands). */
|
|
#[On('keyRemoved')]
|
|
public function removeKey(string $fingerprint): void
|
|
{
|
|
$this->sshKeys = array_values(array_filter(
|
|
$this->sshKeys,
|
|
fn (array $k): bool => $k['fingerprint'] !== $fingerprint,
|
|
));
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.servers.show');
|
|
}
|
|
}
|