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.

Merge remote-tracking branch 'origin/next' into audit-policies

Andras Bacsai973632b49cea
diff --cc app/Livewire/Project/Database/Clickhouse/General.php
index a200d55e39,6946743266..ad5e45b3fe
--- a/app/Livewire/Project/Database/Clickhouse/General.php
+++ b/app/Livewire/Project/Database/Clickhouse/General.php
@@@ -40,20 -40,21 +40,23 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public ?string $dbUrl = null;
-
- public ?string $dbUrlPublic = null;
-
public bool $isLogDrainEnabled = false;
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
+ public function getListeners(): array
{
- $teamId = Auth::user()->currentTeam()->id;
+ $user = Auth::user();
+ if (! $user) {
+ return [];
+ }
+ $team = $user->currentTeam();
+ if (! $team) {
+ return [];
+ }
return [
- "echo-private:team.{$teamId},DatabaseProxyStopped" => 'databaseProxyStopped',
+ "echo-private:team.{$team->id},DatabaseProxyStopped" => 'databaseProxyStopped',
];
}
@@@ -71,13 -72,6 +74,11 @@@
} catch (\Throwable $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->clickhouseAdminPassword = '';
- $this->dbUrl = null;
- $this->dbUrlPublic = null;
+ }
}
protected function rules(): array
diff --cc app/Livewire/Project/Database/Dragonfly/General.php
index 1f29d42904,f196b9dfb1..2f5b844845
--- a/app/Livewire/Project/Database/Dragonfly/General.php
+++ b/app/Livewire/Project/Database/Dragonfly/General.php
@@@ -40,27 -38,21 +38,23 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public ?string $dbUrl = null;
-
- public ?string $dbUrlPublic = null;
-
public bool $isLogDrainEnabled = false;
- public ?Carbon $certificateValidUntil = null;
-
- public bool $enable_ssl = false;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
+ public function getListeners(): array
{
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
+ $user = Auth::user();
+ if (! $user) {
+ return [];
+ }
+ $team = $user->currentTeam();
+ if (! $team) {
+ return [];
+ }
return [
- "echo-private:team.{$teamId},DatabaseProxyStopped" => 'databaseProxyStopped',
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
+ "echo-private:team.{$team->id},DatabaseProxyStopped" => 'databaseProxyStopped',
];
}
@@@ -78,19 -70,6 +72,11 @@@
} catch (\Throwable $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->dragonflyPassword = '';
- $this->dbUrl = null;
- $this->dbUrlPublic = null;
+ }
}
protected function rules(): array
diff --cc app/Livewire/Project/Database/Keydb/General.php
index 4bf2165fbf,974803e8d3..b2d9bce91b
--- a/app/Livewire/Project/Database/Keydb/General.php
+++ b/app/Livewire/Project/Database/Keydb/General.php
@@@ -42,27 -40,21 +40,23 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public ?string $dbUrl = null;
-
- public ?string $dbUrlPublic = null;
-
public bool $isLogDrainEnabled = false;
- public ?Carbon $certificateValidUntil = null;
-
- public bool $enable_ssl = false;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
+ public function getListeners(): array
{
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
+ $user = Auth::user();
+ if (! $user) {
+ return [];
+ }
+ $team = $user->currentTeam();
+ if (! $team) {
+ return [];
+ }
return [
- "echo-private:team.{$teamId},DatabaseProxyStopped" => 'databaseProxyStopped',
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
+ "echo-private:team.{$team->id},DatabaseProxyStopped" => 'databaseProxyStopped',
];
}
@@@ -80,19 -72,6 +74,11 @@@
} catch (\Throwable $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->keydbPassword = '';
- $this->dbUrl = null;
- $this->dbUrlPublic = null;
+ }
}
protected function rules(): array
diff --cc app/Livewire/Project/Database/Mariadb/General.php
index 95666cc24f,41266f1522..61280a34b5
--- a/app/Livewire/Project/Database/Mariadb/General.php
+++ b/app/Livewire/Project/Database/Mariadb/General.php
@@@ -50,27 -47,6 +47,8 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public bool $enableSsl = false;
-
- public ?string $db_url = null;
-
- public ?string $db_url_public = null;
-
- public ?Carbon $certificateValidUntil = null;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
- {
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- ];
- }
-
protected function rules(): array
{
return [
@@@ -152,20 -126,6 +128,12 @@@
} catch (Exception $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->mariadbRootPassword = '';
+ $this->mariadbPassword = '';
- $this->db_url = null;
- $this->db_url_public = null;
+ }
}
public function syncData(bool $toModel = false)
diff --cc app/Livewire/Project/Database/Mongodb/General.php
index c648024663,7d8249ec40..f68ba82c7d
--- a/app/Livewire/Project/Database/Mongodb/General.php
+++ b/app/Livewire/Project/Database/Mongodb/General.php
@@@ -48,29 -45,6 +45,8 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public bool $enableSsl = false;
-
- public ?string $sslMode = null;
-
- public ?string $db_url = null;
-
- public ?string $db_url_public = null;
-
- public ?Carbon $certificateValidUntil = null;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
- {
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- ];
- }
-
protected function rules(): array
{
return [
@@@ -150,19 -119,6 +121,11 @@@
} catch (Exception $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->mongoInitdbRootPassword = '';
- $this->db_url = null;
- $this->db_url_public = null;
+ }
}
public function syncData(bool $toModel = false)
diff --cc app/Livewire/Project/Database/Mysql/General.php
index 49f2041863,6b88d735de..1adfe2ea79
--- a/app/Livewire/Project/Database/Mysql/General.php
+++ b/app/Livewire/Project/Database/Mysql/General.php
@@@ -50,29 -47,6 +47,8 @@@ class General extends Componen
public ?string $customDockerRunOptions = null;
- public bool $enableSsl = false;
-
- public ?string $sslMode = null;
-
- public ?string $db_url = null;
-
- public ?string $db_url_public = null;
-
- public ?Carbon $certificateValidUntil = null;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
- {
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- ];
- }
-
protected function rules(): array
{
return [
@@@ -157,20 -126,6 +128,12 @@@
} catch (Exception $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->mysqlRootPassword = '';
+ $this->mysqlPassword = '';
- $this->db_url = null;
- $this->db_url_public = null;
+ }
}
public function syncData(bool $toModel = false)
diff --cc app/Livewire/Project/Database/Postgresql/General.php
index 38cb770e61,4e89e8b62f..8993cc251b
--- a/app/Livewire/Project/Database/Postgresql/General.php
+++ b/app/Livewire/Project/Database/Postgresql/General.php
@@@ -62,26 -55,10 +55,12 @@@ class General extends Componen
public string $new_content;
- public ?string $db_url = null;
-
- public ?string $db_url_public = null;
-
- public ?Carbon $certificateValidUntil = null;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
- {
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- 'save_init_script',
- 'delete_init_script',
- ];
- }
+ protected $listeners = [
+ 'save_init_script',
+ 'delete_init_script',
+ ];
protected function rules(): array
{
@@@ -168,19 -140,6 +142,11 @@@
} catch (Exception $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->postgresPassword = '';
- $this->db_url = null;
- $this->db_url_public = null;
+ }
}
public function syncData(bool $toModel = false)
diff --cc app/Livewire/Project/Database/Redis/General.php
index 7d1979435e,aff7b7afa0..d431b15064
--- a/app/Livewire/Project/Database/Redis/General.php
+++ b/app/Livewire/Project/Database/Redis/General.php
@@@ -48,27 -45,9 +45,11 @@@ class General extends Componen
public string $redisVersion;
- public ?string $dbUrl = null;
-
- public ?string $dbUrlPublic = null;
-
- public bool $enableSsl = false;
-
- public ?Carbon $certificateValidUntil = null;
-
+ public bool $isPasswordHiddenForMember = false;
+
- public function getListeners()
- {
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- 'envsUpdated' => 'refresh',
- ];
- }
+ protected $listeners = [
+ 'envsUpdated' => 'refresh',
+ ];
protected function rules(): array
{
@@@ -141,19 -118,6 +120,11 @@@
} catch (\Throwable $e) {
return handleError($e, $this);
}
+
+ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ if ($this->isPasswordHiddenForMember) {
+ $this->redisPassword = '';
- $this->dbUrl = null;
- $this->dbUrlPublic = null;
+ }
}
public function syncData(bool $toModel = false)
diff --cc app/Livewire/Project/DeleteEnvironment.php
index 28027ce5af,4d28c7676b..3d77676990
--- a/app/Livewire/Project/DeleteEnvironment.php
+++ b/app/Livewire/Project/DeleteEnvironment.php
@@@ -30,22 -28,18 +28,22 @@@ class DeleteEnvironment extends Compone
public function delete()
{
- $this->validate([
- 'environment_id' => 'required|int',
- ]);
- $environment = Environment::ownedByCurrentTeam()->findOrFail($this->environment_id);
- $this->authorize('delete', $environment);
-
- if ($environment->isEmpty()) {
- $environment->delete();
-
- return redirectRoute($this, 'project.show', ['project_uuid' => $this->parameters['project_uuid']]);
+ try {
+ $this->validate([
+ 'environment_id' => 'required|int',
+ ]);
- $environment = Environment::findOrFail($this->environment_id);
++ $environment = Environment::ownedByCurrentTeam()->findOrFail($this->environment_id);
+ $this->authorize('delete', $environment);
+
+ if ($environment->isEmpty()) {
+ $environment->delete();
+
+ return redirectRoute($this, 'project.show', ['project_uuid' => $this->parameters['project_uuid']]);
+ }
+
+ return $this->dispatch('error', "<strong>Environment {$environment->name}</strong> has defined resources, please delete them first.");
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
}
-
- return $this->dispatch('error', "<strong>Environment {$environment->name}</strong> has defined resources, please delete them first.");
}
}
diff --cc app/Livewire/Project/Service/Heading.php
index 20502393bd,60273ab232..34bb46ff19
--- a/app/Livewire/Project/Service/Heading.php
+++ b/app/Livewire/Project/Service/Heading.php
@@@ -102,20 -110,17 +110,20 @@@ class Heading extends Componen
public function start()
{
- $this->authorizeService('deploy');
-
- $activity = StartService::run($this->service, pullLatestImages: true);
- $this->dispatch('activityMonitor', $activity->id);
+ try {
- $this->authorize('deploy', $this->service);
++ $this->authorizeService('deploy');
+ $activity = StartService::run($this->service, pullLatestImages: true);
+ $this->js("window.dispatchEvent(new CustomEvent('startservice'))");
+ $this->dispatch('activityMonitor', $activity->id);
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
}
public function forceDeploy()
{
- $this->authorizeService('deploy');
-
try {
- $this->authorize('deploy', $this->service);
++ $this->authorizeService('deploy');
$activities = Activity::where('properties->type_uuid', $this->service->uuid)
->where(function ($q) {
$q->where('properties->status', ProcessStatus::IN_PROGRESS->value)
@@@ -135,50 -139,52 +143,59 @@@
public function stop()
{
- $this->authorizeService('stop');
-
try {
- $this->authorize('stop', $this->service);
++ $this->authorizeService('stop');
StopService::dispatch($this->service, false, $this->docker_cleanup);
- } catch (\Exception $e) {
- $this->dispatch('error', $e->getMessage());
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
}
}
public function restart()
{
- $this->authorizeService('deploy');
-
- $this->checkDeployments();
- if ($this->isDeploymentProgress) {
- $this->dispatch('error', 'There is a deployment in progress.');
+ try {
- $this->authorize('deploy', $this->service);
++ $this->authorizeService('deploy');
+ $this->checkDeployments();
+ if ($this->isDeploymentProgress) {
+ $this->dispatch('error', 'There is a deployment in progress.');
- return;
+ return;
+ }
+ $activity = StartService::run($this->service, stopBeforeStart: true);
+ $this->js("window.dispatchEvent(new CustomEvent('startservice'))");
+ $this->dispatch('activityMonitor', $activity->id);
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
}
- $activity = StartService::run($this->service, stopBeforeStart: true);
- $this->dispatch('activityMonitor', $activity->id);
}
public function pullAndRestartEvent()
{
- $this->authorizeService('deploy');
-
- $this->checkDeployments();
- if ($this->isDeploymentProgress) {
- $this->dispatch('error', 'There is a deployment in progress.');
+ try {
- $this->authorize('deploy', $this->service);
++ $this->authorizeService('deploy');
+ $this->checkDeployments();
+ if ($this->isDeploymentProgress) {
+ $this->dispatch('error', 'There is a deployment in progress.');
- return;
+ return;
+ }
+ $activity = StartService::run($this->service, pullLatestImages: true, stopBeforeStart: true);
+ $this->js("window.dispatchEvent(new CustomEvent('startservice'))");
+ $this->dispatch('activityMonitor', $activity->id);
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
}
- $activity = StartService::run($this->service, pullLatestImages: true, stopBeforeStart: true);
- $this->dispatch('activityMonitor', $activity->id);
}
+ private function authorizeService(string $ability): void
+ {
+ $this->service = Service::ownedByCurrentTeam()
+ ->whereKey($this->service->getKey())
+ ->firstOrFail();
+
+ $this->authorize($ability, $this->service);
+ }
+
public function render()
{
return view('livewire.project.service.heading', [
diff --cc app/Livewire/Project/Shared/Destination.php
index 8fcca452ac,715ce82a73..51965e81fa
--- a/app/Livewire/Project/Shared/Destination.php
+++ b/app/Livewire/Project/Shared/Destination.php
@@@ -116,17 -111,24 +116,24 @@@ class Destination extends Componen
public function promote(int $network_id, int $server_id)
{
try {
+ $server = Server::ownedByCurrentTeam()->findOrFail($server_id);
+ $network = StandaloneDocker::ownedByCurrentTeam()->where('server_id', $server->id)->findOrFail($network_id);
$this->authorize('update', $this->resource);
- $main_destination = $this->resource->destination;
- $this->resource->update([
- 'destination_id' => $network_id,
- 'destination_type' => StandaloneDocker::class,
- ]);
- $this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]);
- $this->resource->additional_networks()->attach($main_destination->id, ['server_id' => $main_destination->server->id]);
- $this->refreshServers();
+
+ $this->resource->getConnection()->transaction(function () use ($network, $server) {
+ $main_destination = $this->resource->destination;
+ $this->resource->update([
+ 'destination_id' => $network->id,
+ 'destination_type' => StandaloneDocker::class,
+ ]);
+ $this->resource->additional_networks()
+ ->wherePivot('server_id', $server->id)
+ ->detach($network->id);
+ $this->resource->additional_networks()->attach($main_destination->id, ['server_id' => $main_destination->server->id]);
+ });
$this->resource->refresh();
+ $this->refreshServers();
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
return handleError($e, $this);
}
}
@@@ -141,10 -143,13 +148,13 @@@
public function addServer(int $network_id, int $server_id)
{
try {
+ $server = Server::ownedByCurrentTeam()->findOrFail($server_id);
+ $network = StandaloneDocker::ownedByCurrentTeam()->where('server_id', $server->id)->findOrFail($network_id);
$this->authorize('update', $this->resource);
- $this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);
+
+ $this->resource->additional_networks()->attach($network->id, ['server_id' => $server->id]);
$this->dispatch('refresh');
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
return handleError($e, $this);
}
}
diff --cc app/Livewire/Security/ApiTokens.php
index 08503359e9,c275ec097b..bf201e257f
--- a/app/Livewire/Security/ApiTokens.php
+++ b/app/Livewire/Security/ApiTokens.php
@@@ -29,14 -30,12 +30,18 @@@ class ApiTokens extends Componen
public $isApiEnabled;
+ #[Locked]
public bool $canUseRootPermissions = false;
+ #[Locked]
public bool $canUseWritePermissions = false;
++ #[Locked]
+ public bool $canUseDeployPermissions = false;
+
++ #[Locked]
+ public bool $canUseSensitivePermissions = false;
+
public function render()
{
return view('livewire.security.api-tokens');
@@@ -59,38 -56,26 +64,38 @@@
public function updatedPermissions($permissionToUpdate)
{
- // Re-evaluate policies fresh — never trust stored snapshot booleans
- // Check if user is trying to use restricted permissions
++ // Re-evaluate policies fresh — never trust stored snapshot booleans.
if ($permissionToUpdate == 'root' && ! auth()->user()->can('useRootPermissions', PersonalAccessToken::class)) {
$this->dispatch('error', 'You do not have permission to use root permissions.');
- // Remove root from permissions if it was somehow added
$this->permissions = array_diff($this->permissions, ['root']);
return;
}
- if (in_array($permissionToUpdate, ['write', 'write:sensitive']) && ! auth()->user()->can('useWritePermissions', PersonalAccessToken::class)) {
+ if (in_array($permissionToUpdate, ['write', 'write:sensitive'], true) && ! auth()->user()->can('useWritePermissions', PersonalAccessToken::class)) {
$this->dispatch('error', 'You do not have permission to use write permissions.');
- // Remove write permissions if they were somehow added
$this->permissions = array_diff($this->permissions, ['write', 'write:sensitive']);
return;
}
+ if ($permissionToUpdate == 'deploy' && ! auth()->user()->can('useDeployPermissions', PersonalAccessToken::class)) {
+ $this->dispatch('error', 'You do not have permission to use deploy permissions.');
+ $this->permissions = array_diff($this->permissions, ['deploy']);
+
+ return;
+ }
+
+ if ($permissionToUpdate == 'read:sensitive' && ! auth()->user()->can('useSensitivePermissions', PersonalAccessToken::class)) {
+ $this->dispatch('error', 'You do not have permission to use read:sensitive permissions.');
+ $this->permissions = array_diff($this->permissions, ['read:sensitive']);
+
+ return;
+ }
+
if ($permissionToUpdate == 'root') {
$this->permissions = ['root'];
- } elseif ($permissionToUpdate == 'read:sensitive' && ! in_array('read', $this->permissions)) {
+ } elseif ($permissionToUpdate == 'read:sensitive' && ! in_array('read', $this->permissions, true)) {
$this->permissions[] = 'read';
} elseif ($permissionToUpdate == 'deploy') {
$this->permissions = ['deploy'];
@@@ -107,10 -92,8 +112,10 @@@
try {
$this->authorize('create', PersonalAccessToken::class);
- // Validate permissions based on user role
+ // Re-evaluate policies fresh against the current authenticated user.
+ // Never trust $this->canUse* booleans — they come from the Livewire
+ // snapshot which can be replayed from another user's session.
- if (in_array('root', $this->permissions) && ! auth()->user()->can('useRootPermissions', PersonalAccessToken::class)) {
+ if (in_array('root', $this->permissions, true) && ! auth()->user()->can('useRootPermissions', PersonalAccessToken::class)) {
throw new \Exception('You do not have permission to create tokens with root permissions.');
}
@@@ -118,14 -101,6 +123,14 @@@
throw new \Exception('You do not have permission to create tokens with write permissions.');
}
- if (in_array('deploy', $this->permissions) && ! auth()->user()->can('useDeployPermissions', PersonalAccessToken::class)) {
++ if (in_array('deploy', $this->permissions, true) && ! auth()->user()->can('useDeployPermissions', PersonalAccessToken::class)) {
+ throw new \Exception('You do not have permission to create tokens with deploy permissions.');
+ }
+
- if (in_array('read:sensitive', $this->permissions) && ! auth()->user()->can('useSensitivePermissions', PersonalAccessToken::class)) {
++ if (in_array('read:sensitive', $this->permissions, true) && ! auth()->user()->can('useSensitivePermissions', PersonalAccessToken::class)) {
+ throw new \Exception('You do not have permission to create tokens with read:sensitive permissions.');
+ }
+
$this->validate([
'description' => 'required|min:3|max:255',
'expiresInDays' => 'nullable|integer|in:7,30,60,90,365',
diff --cc app/Livewire/Server/Proxy/DynamicConfigurationNavbar.php
index f7db1257cb,20d14ddc74..4ea21e4ae4
--- a/app/Livewire/Server/Proxy/DynamicConfigurationNavbar.php
+++ b/app/Livewire/Server/Proxy/DynamicConfigurationNavbar.php
@@@ -22,38 -22,33 +22,37 @@@ class DynamicConfigurationNavbar extend
public function delete(string $fileName)
{
- $this->authorize('update', $this->server);
- $proxy_path = $this->server->proxyPath();
- $proxy_type = $this->server->proxyType();
-
- // Decode filename: pipes are used to encode dots for Livewire property binding
- // (e.g., 'my|service.yaml' -> 'my.service.yaml')
- // This must happen BEFORE validation because validateFilenameSafe()
- // rejects pipe characters through validateShellSafePath().
- $file = str_replace('|', '.', $fileName);
-
- validateFilenameSafe($file, 'proxy configuration filename');
-
- if ($proxy_type === 'CADDY' && $file === 'Caddyfile') {
- $this->dispatch('error', 'Cannot delete Caddyfile.');
-
- return;
- }
-
- $fullPath = "{$proxy_path}/dynamic/{$file}";
- $escapedPath = escapeshellarg($fullPath);
- instant_remote_process(["rm -f {$escapedPath}"], $this->server);
- if ($proxy_type === 'CADDY') {
- $this->server->reloadCaddy();
+ try {
+ $this->authorize('update', $this->server);
+ $proxy_path = $this->server->proxyPath();
+ $proxy_type = $this->server->proxyType();
+
+ // Decode filename: pipes are used to encode dots for Livewire property binding
+ // (e.g., 'my|service.yaml' -> 'my.service.yaml')
- // This must happen BEFORE validation because validateShellSafePath() correctly
- // rejects pipe characters as dangerous shell metacharacters
++ // This must happen BEFORE validation because validateFilenameSafe()
++ // rejects pipe characters through validateShellSafePath().
+ $file = str_replace('|', '.', $fileName);
+
- // Validate filename to prevent command injection
- validateShellSafePath($file, 'proxy configuration filename');
++ validateFilenameSafe($file, 'proxy configuration filename');
+
+ if ($proxy_type === 'CADDY' && $file === 'Caddyfile') {
+ $this->dispatch('error', 'Cannot delete Caddyfile.');
+
+ return;
+ }
+
+ $fullPath = "{$proxy_path}/dynamic/{$file}";
+ $escapedPath = escapeshellarg($fullPath);
+ instant_remote_process(["rm -f {$escapedPath}"], $this->server);
+ if ($proxy_type === 'CADDY') {
+ $this->server->reloadCaddy();
+ }
+ $this->dispatch('success', 'File deleted.');
+ $this->dispatch('loadDynamicConfigurations');
+ $this->dispatch('refresh');
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
}
- $this->dispatch('success', 'File deleted.');
- $this->dispatch('loadDynamicConfigurations');
- $this->dispatch('refresh');
}
public function render()
diff --cc app/Models/S3Storage.php
index bcbbe526ee,190ee6e672..3b344dfff1
--- a/app/Models/S3Storage.php
+++ b/app/Models/S3Storage.php
@@@ -164,30 -173,27 +173,31 @@@ class S3Storage extends BaseMode
$this->unusable_email_sent = false;
$this->is_usable = true;
} catch (\Throwable $e) {
+ $exception = $this->toUserFriendlyConnectionException($e);
$this->is_usable = false;
if ($this->unusable_email_sent === false && is_transactional_emails_enabled()) {
- $mail = new MailMessage;
- $mail->subject('Coolify: S3 Storage Connection Error');
- $mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $exception->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
-
- // Load the team with its members and their roles explicitly
- $team = $this->team()->with(['members' => function ($query) {
- $query->withPivot('role');
- }])->first();
-
- // Get admins directly from the pivot relationship for this specific team
- $users = $team->members()->wherePivotIn('role', ['admin', 'owner'])->get(['users.id', 'users.email']);
- foreach ($users as $user) {
- send_user_an_email($mail, $user->email);
+ try {
+ $mail = new MailMessage;
+ $mail->subject('Coolify: S3 Storage Connection Error');
- $mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
++ $mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $exception->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
+
+ // Load the team with its members and their roles explicitly
+ $team = $this->team()->with(['members' => function ($query) {
+ $query->withPivot('role');
+ }])->first();
+
+ // Get admins directly from the pivot relationship for this specific team
+ $users = $team->members()->wherePivotIn('role', ['admin', 'owner'])->get(['users.id', 'users.email']);
+ foreach ($users as $user) {
+ send_user_an_email($mail, $user->email);
+ }
+ $this->unusable_email_sent = true;
+ } catch (\Throwable $emailException) {
+ \Log::warning('Failed to send S3 connection error notification: '.$emailException->getMessage());
}
- $this->unusable_email_sent = true;
}
- throw $e;
+ throw $exception;
} finally {
if ($shouldSave) {
$this->save();
diff --cc app/Traits/HasDatabaseStatusInfo.php
index 0000000000,e46cccf0c0..5127e05958
mode 000000,100644..100644
--- a/app/Traits/HasDatabaseStatusInfo.php
+++ b/app/Traits/HasDatabaseStatusInfo.php
@@@ -1,0 -1,172 +1,181 @@@
+ <?php
+
+ namespace App\Traits;
+
+ use App\Helpers\SslHelper;
+ use Carbon\Carbon;
+ use Exception;
+ use Illuminate\Contracts\View\View;
+ use Illuminate\Support\Facades\Auth;
+
+ /**
+ * Shared behavior for the per-database StatusInfo Livewire siblings.
+ *
+ * Lives on a child Livewire component so status broadcasts never trigger a
+ * roundtrip on the parent form — preserving in-progress typing AND wire:dirty.
+ * See coolify#6062 / #6354 / #9695.
+ *
+ * Consumers must declare a typed `public Model $database` and implement
+ * databaseLabel(). All other hooks have sensible defaults.
+ */
+ trait HasDatabaseStatusInfo
+ {
+ public ?string $dbUrl = null;
+
+ public ?string $dbUrlPublic = null;
+
+ public bool $enableSsl = false;
+
+ public ?string $sslMode = null;
+
+ public ?Carbon $certificateValidUntil = null;
+
++ public bool $isPasswordHiddenForMember = false;
++
+ abstract protected function databaseLabel(): string;
+
+ protected function supportsSsl(): bool
+ {
+ return true;
+ }
+
+ protected function sslModeOptions(): ?array
+ {
+ return null;
+ }
+
+ protected function sslModeHelper(): ?string
+ {
+ return null;
+ }
+
+ protected function showPublicUrlPlaceholder(): bool
+ {
+ return false;
+ }
+
+ public function getListeners(): array
+ {
+ $listeners = ['databaseUpdated' => 'refresh'];
+
+ $user = Auth::user();
+ if (! $user) {
+ return $listeners;
+ }
+
+ $listeners["echo-private:user.{$user->id},DatabaseStatusChanged"] = 'refresh';
+
+ $team = $user->currentTeam();
+ if ($team) {
+ $listeners["echo-private:team.{$team->id},ServiceChecked"] = 'refresh';
+ }
+
+ return $listeners;
+ }
+
+ public function mount(): void
+ {
++ $this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;
+ $this->refresh();
+ }
+
+ public function refresh(): void
+ {
+ $this->database->refresh();
- $this->dbUrl = $this->database->internal_db_url;
- $this->dbUrlPublic = $this->database->external_db_url;
++ if ($this->isPasswordHiddenForMember) {
++ $this->dbUrl = null;
++ $this->dbUrlPublic = null;
++ } else {
++ $this->dbUrl = $this->database->internal_db_url;
++ $this->dbUrlPublic = $this->database->external_db_url;
++ }
+ if ($this->supportsSsl()) {
+ $this->enableSsl = (bool) $this->database->enable_ssl;
+ $this->certificateValidUntil = $this->database->sslCertificates()->first()?->valid_until;
+ $this->afterRefresh();
+ }
+ }
+
+ /**
+ * Hook for subclasses with extra status-derived properties (e.g. sslMode).
+ */
+ protected function afterRefresh(): void {}
+
+ public function instantSaveSSL(): void
+ {
+ try {
+ $this->authorize('update', $this->database);
+ $this->database->enable_ssl = $this->enableSsl;
+ $this->applyExtraSslAttributes();
+ $this->database->save();
+ $this->dispatch('success', 'SSL configuration updated.');
+ } catch (Exception $e) {
+ handleError($e, $this);
+ }
+ }
+
+ /**
+ * Hook for subclasses with additional SSL columns to persist (e.g. ssl_mode).
+ */
+ protected function applyExtraSslAttributes(): void {}
+
+ public function regenerateSslCertificate(): void
+ {
+ try {
+ $this->authorize('update', $this->database);
+
+ $existingCert = $this->database->sslCertificates()->first();
+
+ if (! $existingCert) {
+ $this->dispatch('error', 'No existing SSL certificate found for this database.');
+
+ return;
+ }
+
+ $server = $this->database->destination->server;
+ $caCert = $server->sslCertificates()->where('is_ca_certificate', true)->first();
+
+ if (! $caCert) {
+ $server->generateCaCertificate();
+ $caCert = $server->sslCertificates()->where('is_ca_certificate', true)->first();
+ }
+
+ if (! $caCert) {
+ $this->dispatch('error', 'No CA certificate found for this database. Please generate a CA certificate for this server in the server/advanced page.');
+
+ return;
+ }
+
+ SslHelper::generateSslCertificate(
+ commonName: $existingCert->common_name,
+ subjectAlternativeNames: $existingCert->subject_alternative_names ?? [],
+ resourceType: $existingCert->resource_type,
+ resourceId: $existingCert->resource_id,
+ serverId: $existingCert->server_id,
+ caCert: $caCert->ssl_certificate,
+ caKey: $caCert->ssl_private_key,
+ configurationDir: $existingCert->configuration_dir,
+ mountPath: $existingCert->mount_path,
+ isPemKeyFileRequired: true,
+ );
+
+ $this->refresh();
+ $this->dispatch('success', 'SSL certificates regenerated. Restart database to apply changes.');
+ } catch (Exception $e) {
+ handleError($e, $this);
+ }
+ }
+
+ public function render(): View
+ {
+ return view('livewire.project.database.status-info', [
+ 'label' => $this->databaseLabel(),
+ 'supportsSsl' => $this->supportsSsl(),
+ 'sslModeOptions' => $this->sslModeOptions(),
+ 'sslModeHelper' => $this->sslModeHelper(),
+ 'showPublicUrlPlaceholder' => $this->showPublicUrlPlaceholder(),
+ 'isExited' => str($this->database->status)->contains('exited'),
++ 'isPasswordHiddenForMember' => $this->isPasswordHiddenForMember,
+ ]);
+ }
+ }
diff --cc resources/views/components/database-status-info.blade.php
index 0000000000,4a9de3ca57..24116db259
mode 000000,100644..100644
--- a/resources/views/components/database-status-info.blade.php
+++ b/resources/views/components/database-status-info.blade.php
@@@ -1,0 -1,94 +1,100 @@@
+ @props([
+ 'database',
+ 'label',
+ 'dbUrl' => null,
+ 'dbUrlPublic' => null,
+ 'supportsSsl' => true,
+ 'enableSsl' => false,
+ 'sslMode' => null,
+ 'sslModeOptions' => null,
+ 'sslModeHelper' => null,
+ 'certificateValidUntil' => null,
+ 'isExited' => false,
+ 'showPublicUrlPlaceholder' => false,
++ 'isPasswordHiddenForMember' => false,
+ ])
+
+ @php
+ $urlHelper = 'If you change the user/password/port, this could be different. This is with the default values.';
+ @endphp
+
+ <div class="flex flex-col gap-2">
- <x-forms.input :label="$label . ' URL (internal)'" :helper="$urlHelper" type="password" readonly
- wire:model="dbUrl" canGate="update" :canResource="$database" />
- @if ($dbUrlPublic)
- <x-forms.input :label="$label . ' URL (public)'" :helper="$urlHelper" type="password" readonly
- wire:model="dbUrlPublic" canGate="update" :canResource="$database" />
- @elseif ($showPublicUrlPlaceholder)
- <x-forms.input :label="$label . ' URL (public)'" :helper="$urlHelper" readonly
- value="Starting the database will generate this." canGate="update" :canResource="$database" />
++ @if ($isPasswordHiddenForMember)
++ <x-forms.input :label="$label . ' URL (internal)'" disabled value="Hidden (only admins can view)" />
++ <x-forms.input :label="$label . ' URL (public)'" disabled value="Hidden (only admins can view)" />
++ @else
++ <x-forms.input :label="$label . ' URL (internal)'" :helper="$urlHelper" type="password" readonly
++ wire:model="dbUrl" canGate="update" :canResource="$database" />
++ @if ($dbUrlPublic)
++ <x-forms.input :label="$label . ' URL (public)'" :helper="$urlHelper" type="password" readonly
++ wire:model="dbUrlPublic" canGate="update" :canResource="$database" />
++ @elseif ($showPublicUrlPlaceholder)
++ <x-forms.input :label="$label . ' URL (public)'" :helper="$urlHelper" readonly
++ value="Starting the database will generate this." canGate="update" :canResource="$database" />
++ @endif
+ @endif
+
+ @if ($supportsSsl)
+ <div class="flex flex-col gap-2 pt-4">
+ <div class="flex items-center justify-between py-2">
+ <div class="flex items-center justify-between w-full">
+ <h3>SSL Configuration</h3>
+ @if ($enableSsl && $certificateValidUntil)
+ <x-modal-confirmation title="Regenerate SSL Certificates"
+ buttonTitle="Regenerate SSL Certificates" :actions="[
+ 'The SSL certificate of this database will be regenerated.',
+ 'You must restart the database after regenerating the certificate to start using the new certificate.',
+ ]"
+ submitAction="regenerateSslCertificate" :confirmWithText="false" :confirmWithPassword="false" />
+ @endif
+ </div>
+ </div>
+ @if ($enableSsl && $certificateValidUntil)
+ <span class="text-sm">Valid until:
+ @if (now()->gt($certificateValidUntil))
+ <span class="text-red-500">{{ $certificateValidUntil->format('d.m.Y H:i:s') }} - Expired</span>
+ @elseif(now()->addDays(30)->gt($certificateValidUntil))
+ <span class="text-red-500">{{ $certificateValidUntil->format('d.m.Y H:i:s') }} - Expiring
+ soon</span>
+ @else
+ <span>{{ $certificateValidUntil->format('d.m.Y H:i:s') }}</span>
+ @endif
+ </span>
+ @endif
+ <div class="flex flex-col gap-2">
+ <div class="w-64" wire:key="enable_ssl">
+ @if ($isExited)
+ <x-forms.checkbox id="enableSsl" label="Enable SSL" wire:model.live="enableSsl"
+ instantSave="instantSaveSSL" canGate="update" :canResource="$database" />
+ @else
+ <x-forms.checkbox id="enableSsl" label="Enable SSL" wire:model.live="enableSsl"
+ instantSave="instantSaveSSL" disabled
+ helper="Database should be stopped to change this setting." canGate="update"
+ :canResource="$database" />
+ @endif
+ </div>
+ @if ($sslModeOptions && $enableSsl)
+ <div class="mx-2">
+ @if ($isExited)
+ <x-forms.select id="sslMode" label="SSL Mode" wire:model.live="sslMode"
+ instantSave="instantSaveSSL" :helper="$sslModeHelper" canGate="update"
+ :canResource="$database">
+ @foreach ($sslModeOptions as $value => $option)
+ <option value="{{ $value }}" title="{{ $option['title'] ?? '' }}">{{ $option['label'] }}</option>
+ @endforeach
+ </x-forms.select>
+ @else
+ <x-forms.select id="sslMode" label="SSL Mode" instantSave="instantSaveSSL" disabled
+ helper="Database should be stopped to change this setting." canGate="update"
+ :canResource="$database">
+ @foreach ($sslModeOptions as $value => $option)
+ <option value="{{ $value }}" title="{{ $option['title'] ?? '' }}">{{ $option['label'] }}</option>
+ @endforeach
+ </x-forms.select>
+ @endif
+ </div>
+ @endif
+ </div>
+ </div>
+ @endif
+ </div>
diff --cc resources/views/livewire/project/database/status-info.blade.php
index 0000000000,7107b3daf8..3e3c97c805
mode 000000,100644..100644
--- a/resources/views/livewire/project/database/status-info.blade.php
+++ b/resources/views/livewire/project/database/status-info.blade.php
@@@ -1,0 -1,6 +1,7 @@@
+ <div>
+ <x-database-status-info :database="$database" :label="$label" :db-url="$dbUrl" :db-url-public="$dbUrlPublic"
+ :enable-ssl="$enableSsl" :ssl-mode="$sslMode" :certificate-valid-until="$certificateValidUntil"
+ :supports-ssl="$supportsSsl" :ssl-mode-options="$sslModeOptions" :ssl-mode-helper="$sslModeHelper"
- :show-public-url-placeholder="$showPublicUrlPlaceholder" :is-exited="$isExited" />
++ :show-public-url-placeholder="$showPublicUrlPlaceholder" :is-exited="$isExited"
++ :is-password-hidden-for-member="$isPasswordHiddenForMember" />
+ </div>
diff --cc resources/views/livewire/project/shared/health-checks.blade.php
index 01f42dacec,ac2063c2ee..f69fd71a46
--- a/resources/views/livewire/project/shared/health-checks.blade.php
+++ b/resources/views/livewire/project/shared/health-checks.blade.php
@@@ -1,14 -1,14 +1,14 @@@
<form wire:submit='submit' class="flex flex-col">
<div class="flex items-center gap-2">
- <h2>Healthchecks</h2>
+ <h2>Healthcheck</h2>
<x-forms.button canGate="update" :canResource="$resource" type="submit">Save</x-forms.button>
@if (!$healthCheckEnabled)
- <x-modal-confirmation title="Confirm Healthcheck Enable?" buttonTitle="Enable Healthcheck"
- submitAction="toggleHealthcheck" :actions="['Enable healthcheck for this resource.']"
- warningMessage="If the health check fails, your application will become inaccessible. Please review the <a href='https://coolify.io/docs/knowledge-base/health-checks' target='_blank' class='underline text-white'>Health Checks</a> guide before proceeding!"
- step2ButtonText="Enable Healthcheck" :confirmWithText="false" :confirmWithPassword="false"
- isHighlightedButton>
- </x-modal-confirmation>
+ <x-modal-confirmation :disabled="!auth()->user()->can('update', $resource)" :authDisabled="!auth()->user()->can('update', $resource)" title="Confirm Healthcheck Enable?" buttonTitle="Enable Healthcheck"
+ submitAction="toggleHealthcheck" :actions="['Enable healthcheck for this resource.']"
+ warningMessage="If the health check fails, your application will become inaccessible. Please review the <a href='https://coolify.io/docs/knowledge-base/health-checks' target='_blank' class='underline text-white'>Health Checks</a> guide before proceeding!"
+ step2ButtonText="Enable Healthcheck" :confirmWithText="false" :confirmWithPassword="false"
+ isHighlightedButton>
+ </x-modal-confirmation>
@else
<x-forms.button canGate="update" :canResource="$resource" wire:click="toggleHealthcheck">Disable Healthcheck</x-forms.button>
@endif