From 299db159cb3e67377ea14813ced91239c9a304bf Mon Sep 17 00:00:00 2001 From: ShadowArcanist Date: Tue, 23 Sep 2025 06:32:51 +0530 Subject: [PATCH] Moved terminal access settings to security page --- app/Livewire/Server/Advanced.php | 33 -------- .../Server/Security/TerminalAccess.php | 79 +++++++++++++++++++ .../server/sidebar-security.blade.php | 4 + .../views/livewire/server/advanced.blade.php | 41 ---------- .../server/security/terminal-access.blade.php | 58 ++++++++++++++ routes/web.php | 2 + 6 files changed, 143 insertions(+), 74 deletions(-) create mode 100644 app/Livewire/Server/Security/TerminalAccess.php create mode 100644 resources/views/livewire/server/security/terminal-access.blade.php diff --git a/app/Livewire/Server/Advanced.php b/app/Livewire/Server/Advanced.php index 760c4df0d..bbc3bd96a 100644 --- a/app/Livewire/Server/Advanced.php +++ b/app/Livewire/Server/Advanced.php @@ -27,9 +27,6 @@ class Advanced extends Component #[Validate(['integer', 'min:1'])] public int $dynamicTimeout = 1; - #[Validate(['boolean'])] - public bool $isTerminalEnabled = false; - public function mount(string $server_uuid) { try { @@ -42,36 +39,7 @@ public function mount(string $server_uuid) } } - public function toggleTerminal($password) - { - try { - // Check if user is admin or owner - if (! auth()->user()->isAdmin()) { - throw new \Exception('Only team administrators and owners can modify terminal access.'); - } - // Verify password unless two-step confirmation is disabled - if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) { - if (! Hash::check($password, Auth::user()->password)) { - $this->addError('password', 'The provided password is incorrect.'); - - return; - } - } - - // Toggle the terminal setting - $this->server->settings->is_terminal_enabled = ! $this->server->settings->is_terminal_enabled; - $this->server->settings->save(); - - // Update the local property - $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; - - $status = $this->isTerminalEnabled ? 'enabled' : 'disabled'; - $this->dispatch('success', "Terminal access has been {$status}."); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } public function syncData(bool $toModel = false) { @@ -88,7 +56,6 @@ public function syncData(bool $toModel = false) $this->dynamicTimeout = $this->server->settings->dynamic_timeout; $this->serverDiskUsageNotificationThreshold = $this->server->settings->server_disk_usage_notification_threshold; $this->serverDiskUsageCheckFrequency = $this->server->settings->server_disk_usage_check_frequency; - $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; } } diff --git a/app/Livewire/Server/Security/TerminalAccess.php b/app/Livewire/Server/Security/TerminalAccess.php new file mode 100644 index 000000000..c5898314b --- /dev/null +++ b/app/Livewire/Server/Security/TerminalAccess.php @@ -0,0 +1,79 @@ +server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail(); + $this->parameters = get_route_parameters(); + $this->syncData(); + + } catch (\Throwable) { + return redirect()->route('server.index'); + } + } + + public function toggleTerminal($password) + { + try { + // Check if user is admin or owner + if (! auth()->user()->isAdmin()) { + throw new \Exception('Only team administrators and owners can modify terminal access.'); + } + + // Verify password unless two-step confirmation is disabled + if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) { + if (! Hash::check($password, Auth::user()->password)) { + $this->addError('password', 'The provided password is incorrect.'); + + return; + } + } + + // Toggle the terminal setting + $this->server->settings->is_terminal_enabled = ! $this->server->settings->is_terminal_enabled; + $this->server->settings->save(); + + // Update the local property + $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; + + $status = $this->isTerminalEnabled ? 'enabled' : 'disabled'; + $this->dispatch('success', "Terminal access has been {$status}."); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + + public function syncData(bool $toModel = false) + { + if ($toModel) { + $this->authorize('update', $this->server); + $this->validate(); + // No other fields to sync for terminal access + } else { + $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; + } + } + + public function render() + { + return view('livewire.server.security.terminal-access'); + } +} \ No newline at end of file diff --git a/resources/views/components/server/sidebar-security.blade.php b/resources/views/components/server/sidebar-security.blade.php index 6f6d9d8a0..141d32f3b 100644 --- a/resources/views/components/server/sidebar-security.blade.php +++ b/resources/views/components/server/sidebar-security.blade.php @@ -3,4 +3,8 @@ href="{{ route('server.security.patches', $parameters) }}"> Server Patching + + Terminal Access + diff --git a/resources/views/livewire/server/advanced.blade.php b/resources/views/livewire/server/advanced.blade.php index 308a9eed2..6622961c5 100644 --- a/resources/views/livewire/server/advanced.blade.php +++ b/resources/views/livewire/server/advanced.blade.php @@ -14,47 +14,6 @@
Advanced configuration for your server.
-
-

Terminal Access

- - @if ($isTerminalEnabled) - - Enabled - - @else - - Disabled - - @endif -
-
-
- @if (auth()->user()->isAdmin()) -
- - -
- @endif -
-
-

Disk Usage

diff --git a/resources/views/livewire/server/security/terminal-access.blade.php b/resources/views/livewire/server/security/terminal-access.blade.php new file mode 100644 index 000000000..81e9482f1 --- /dev/null +++ b/resources/views/livewire/server/security/terminal-access.blade.php @@ -0,0 +1,58 @@ +
+ + {{ data_get_str($server, 'name')->limit(10) }} > Terminal Access | Coolify + + +
+ +
+
+
+

Terminal Access

+
+
Control terminal access for this server and its containers.
+
+ +
+

Terminal Access

+ + @if ($isTerminalEnabled) + + Enabled + + @else + + Disabled + + @endif +
+
+
+ @if (auth()->user()->isAdmin()) +
+ + +
+ @endif +
+
+
+
+
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index e6567daad..fd2ed8730 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,6 +51,7 @@ use App\Livewire\Server\Proxy\Show as ProxyShow; use App\Livewire\Server\Resources as ResourcesShow; use App\Livewire\Server\Security\Patches; +use App\Livewire\Server\Security\TerminalAccess; use App\Livewire\Server\Show as ServerShow; use App\Livewire\Settings\Advanced as SettingsAdvanced; use App\Livewire\Settings\Index as SettingsIndex; @@ -260,6 +261,7 @@ Route::get('/docker-cleanup', DockerCleanup::class)->name('server.docker-cleanup'); Route::get('/security', fn () => redirect(route('dashboard')))->name('server.security')->middleware('can.update.resource'); Route::get('/security/patches', Patches::class)->name('server.security.patches')->middleware('can.update.resource'); + Route::get('/security/terminal-access', TerminalAccess::class)->name('server.security.terminal-access')->middleware('can.update.resource'); }); Route::get('/destinations', DestinationIndex::class)->name('destination.index'); Route::get('/destination/{destination_uuid}', DestinationShow::class)->name('destination.show');