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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Merge remote-tracking branch 'origin/next' into audit-policies
Andras Bacsai43f33d94ad18
diff --cc app/Http/Controllers/Api/GithubController.phpindex b5cabcde00,9a2cf2b9f0..014d84b238--- a/app/Http/Controllers/Api/GithubController.php+++ b/app/Http/Controllers/Api/GithubController.php@@@ -180,9 -183,8 +183,9 @@@ class GithubController extends Controllif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [GithubApp::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}diff --cc app/Http/Controllers/Api/ProjectController.phpindex 33b28fc597,ec2e300ffe..a068b271d7--- a/app/Http/Controllers/Api/ProjectController.php+++ b/app/Http/Controllers/Api/ProjectController.php@@@ -233,10 -233,9 +234,10 @@@ class ProjectController extends Controlif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [Project::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}$validator = Validator::make($request->all(), [diff --cc app/Http/Controllers/Api/SecurityController.phpindex 4fe7388714,2c62928c23..f8641764d9--- a/app/Http/Controllers/Api/SecurityController.php+++ b/app/Http/Controllers/Api/SecurityController.php@@@ -176,9 -176,8 +177,9 @@@ class SecurityController extends Controif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [PrivateKey::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}$validator = customApiValidator($request->all(), [@@@ -332,8 -331,7 +333,8 @@@'message' => 'Private Key not found.',], 404);}+ $this->authorize('update', $foundKey);- $foundKey->update($request->all());+ $foundKey->update($request->only($allowedFields));return response()->json(serializeApiResponse(['uuid' => $foundKey->uuid,diff --cc app/Http/Controllers/Api/ServersController.phpindex 08271c6cb6,c13c6665c0..9c11faef87--- a/app/Http/Controllers/Api/ServersController.php+++ b/app/Http/Controllers/Api/ServersController.php@@@ -761,9 -791,11 +794,12 @@@ class ServersController extends Controlif (! $server) {return response()->json(['message' => 'Server not found.'], 404);}+ $this->authorize('delete', $server);- if ($server->definedResources()->count() > 0) {- return response()->json(['message' => 'Server has resources, so you need to delete them before.'], 400);++ $force = filter_var($request->query('force', false), FILTER_VALIDATE_BOOLEAN);++ if ($server->definedResources()->count() > 0 && ! $force) {+ return response()->json(['message' => 'Server has resources. Use ?force=true to delete all resources and the server, or delete resources manually first.'], 400);}if ($server->isLocalhost()) {return response()->json(['message' => 'Local server cannot be deleted.'], 400);diff --cc app/Livewire/Boarding/Index.phpindex 289f8c181b,33c75bf706..b16f1abde5--- a/app/Livewire/Boarding/Index.php+++ b/app/Livewire/Boarding/Index.php@@@ -8,8 -8,8 +8,9 @@@ use App\Models\Projectuse App\Models\Server;use App\Models\Team;use App\Services\ConfigurationRepository;+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Illuminate\Support\Collection;+ use Livewire\Attributes\Url;use Livewire\Component;use Visus\Cuid2\Cuid2;diff --cc app/Livewire/Destination/Show.phpindex 448a0d1bd3,9d55d74627..17fb5cea5d--- a/app/Livewire/Destination/Show.php+++ b/app/Livewire/Destination/Show.php@@@ -28,15 -27,12 +27,16 @@@ class Show extends Componenpublic function mount(string $destination_uuid){try {- $destination = StandaloneDocker::whereUuid($destination_uuid)->first() ??- SwarmDocker::whereUuid($destination_uuid)->firstOrFail();-+ $destination = find_destination_for_current_team($destination_uuid);+ if (! $destination) {+ return redirect()->route('destination.index');+ }+ $this->authorize('view', $destination);+$this->destination = $destination;$this->syncData();+ } catch (\Illuminate\Auth\Access\AuthorizationException) {+ abort(403);} catch (\Throwable $e) {return handleError($e, $this);}diff --cc app/Livewire/NavbarDeleteTeam.phpindex 78eafbeb43,8e5478b5eb..52e4460add--- a/app/Livewire/NavbarDeleteTeam.php+++ b/app/Livewire/NavbarDeleteTeam.php@@@ -19,37 -15,29 +19,37 @@@ class NavbarDeleteTeam extends Componen$this->team = currentTeam()->name;}- public function delete($password)+ public function delete($password, $selectedActions = []){- if (! verifyPasswordConfirmation($password, $this)) {- return 'The provided password is incorrect.';- }-- $currentTeam = currentTeam();- $currentTeam->delete();-- $currentTeam->members->each(function ($user) use ($currentTeam) {- if ($user->id === Auth::id()) {- return;+ try {+ if (! verifyPasswordConfirmation($password, $this)) {- return;++ return 'The provided password is incorrect.';}- $user->teams()->detach($currentTeam);- $session = DB::table('sessions')->where('user_id', $user->id)->first();- if ($session) {- DB::table('sessions')->where('id', $session->id)->delete();- }- });-- refreshSession();- return redirectRoute($this, 'team.index');+ $currentTeam = currentTeam();+ $this->authorize('delete', $currentTeam);++ $currentTeam->members->each(function ($user) use ($currentTeam) {+ if ($user->id === Auth::id()) {+ return;+ }+ $user->teams()->detach($currentTeam);+ $session = DB::table('sessions')->where('user_id', $user->id)->first();+ if ($session) {+ DB::table('sessions')->where('id', $session->id)->delete();+ }+ });++ Cache::forget('user:'.Auth::id().':team:'.$currentTeam->id);+ $currentTeam->delete();++ $newTeam = Auth::user()->teams()->first();+ refreshSession($newTeam);++ return redirect()->route('team.index');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }}public function render()diff --cc app/Livewire/Project/Application/Previews.phpindex 50acf76b25,c887e9b833..38246715ae--- a/app/Livewire/Project/Application/Previews.php+++ b/app/Livewire/Project/Application/Previews.php@@@ -215,40 -234,45 +234,52 @@@ class Previews extends Componenpublic function force_deploy_without_cache(int $pull_request_id, ?string $pull_request_html_url = null){- $this->authorize('deploy', $this->application);+ try {+ $this->authorize('deploy', $this->application);- $this->deploy($pull_request_id, $pull_request_html_url, force_rebuild: true);- $dockerRegistryImageTag = null;- if ($this->application->build_pack === 'dockerimage') {- $dockerRegistryImageTag = $this->application->previews()- ->where('pull_request_id', $pull_request_id)- ->value('docker_registry_image_tag');- }++ $dockerRegistryImageTag = null;++ if ($this->application->build_pack === 'dockerimage') {++ $dockerRegistryImageTag = $this->application->previews()++ ->where('pull_request_id', $pull_request_id)++ ->value('docker_registry_image_tag');++ }+- $this->deploy($pull_request_id, $pull_request_html_url, force_rebuild: true, docker_registry_image_tag: $dockerRegistryImageTag);++ $this->deploy($pull_request_id, $pull_request_html_url, force_rebuild: true, docker_registry_image_tag: $dockerRegistryImageTag);+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }}- public function add_and_deploy(int $pull_request_id, ?string $pull_request_html_url = null)+ public function add_and_deploy(int $pull_request_id, ?string $pull_request_html_url = null, ?string $docker_registry_image_tag = null){- $this->authorize('deploy', $this->application);+ try {+ $this->authorize('deploy', $this->application);- $this->add($pull_request_id, $pull_request_html_url);- $this->deploy($pull_request_id, $pull_request_html_url);- $this->add($pull_request_id, $pull_request_html_url, $docker_registry_image_tag);- $this->deploy($pull_request_id, $pull_request_html_url, force_rebuild: false, docker_registry_image_tag: $docker_registry_image_tag);++ $this->add($pull_request_id, $pull_request_html_url, $docker_registry_image_tag);++ $this->deploy($pull_request_id, $pull_request_html_url, force_rebuild: false, docker_registry_image_tag: $docker_registry_image_tag);+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }}- public function deploy(int $pull_request_id, ?string $pull_request_html_url = null, bool $force_rebuild = false)+ public function deploy(int $pull_request_id, ?string $pull_request_html_url = null, bool $force_rebuild = false, ?string $docker_registry_image_tag = null){- $this->authorize('deploy', $this->application);-try {+ $this->authorize('deploy', $this->application);$this->setDeploymentUuid();$found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();- if (! $found && ! is_null($pull_request_html_url)) {- ApplicationPreview::create([+ if (! $found && (! is_null($pull_request_html_url) || ($this->application->build_pack === 'dockerimage' && str($docker_registry_image_tag)->isNotEmpty()))) {+ $found = ApplicationPreview::create(['application_id' => $this->application->id,'pull_request_id' => $pull_request_id,- 'pull_request_html_url' => $pull_request_html_url,+ 'pull_request_html_url' => $pull_request_html_url ?? '',+ 'docker_registry_image_tag' => $docker_registry_image_tag,]);}+ if ($found && $this->application->build_pack === 'dockerimage' && str($docker_registry_image_tag)->isNotEmpty()) {+ $found->docker_registry_image_tag = $docker_registry_image_tag;+ $found->save();+ }$result = queue_application_deployment(application: $this->application,deployment_uuid: $this->deployment_uuid,diff --cc app/Livewire/Project/Database/BackupExecutions.phpindex 5ffe6f5097,1dd93781dd..d27345b8db--- a/app/Livewire/Project/Database/BackupExecutions.php+++ b/app/Livewire/Project/Database/BackupExecutions.php@@@ -78,16 -65,10 +78,16 @@@ class BackupExecutions extends Componen}}- public function deleteBackup($executionId, $password)+ public function deleteBackup($executionId, $password, $selectedActions = []){+ try {+ $this->authorize('manageBackups', $this->database);+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+if (! verifyPasswordConfirmation($password, $this)) {- return;+ return 'The provided password is incorrect.';}$execution = $this->backup->executions()->where('id', $executionId)->first();diff --cc app/Livewire/Project/DeleteProject.phpindex 0b99f57a48,d95041c2dd..598e1f61b2--- a/app/Livewire/Project/DeleteProject.php+++ b/app/Livewire/Project/DeleteProject.php@@@ -26,22 -26,18 +26,22 @@@ class DeleteProject extends Componenpublic function delete(){- $this->validate([- 'project_id' => 'required|int',- ]);- $project = Project::ownedByCurrentTeam()->findOrFail($this->project_id);- $this->authorize('delete', $project);-- if ($project->isEmpty()) {- $project->delete();-- return redirectRoute($this, 'project.index');+ try {+ $this->validate([+ 'project_id' => 'required|int',+ ]);- $project = Project::findOrFail($this->project_id);++ $project = Project::ownedByCurrentTeam()->findOrFail($this->project_id);+ $this->authorize('delete', $project);++ if ($project->isEmpty()) {+ $project->delete();++ return redirectRoute($this, 'project.index');+ }++ return $this->dispatch('error', "<strong>Project {$project->name}</strong> has resources defined, please delete them first.");+ } catch (\Throwable $e) {+ return handleError($e, $this);}-- return $this->dispatch('error', "<strong>Project {$project->name}</strong> has resources defined, please delete them first.");}}diff --cc app/Livewire/Project/Shared/Destination.phpindex 1eb1dc5804,3634717607..8fcca452ac--- a/app/Livewire/Project/Shared/Destination.php+++ b/app/Livewire/Project/Shared/Destination.php@@@ -140,21 -130,15 +140,21 @@@ class Destination extends Componenpublic function addServer(int $network_id, int $server_id){- $this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);- $this->dispatch('refresh');+ try {+ $this->authorize('update', $this->resource);+ $this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);+ $this->dispatch('refresh');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }}- public function removeServer(int $network_id, int $server_id, $password)+ public function removeServer(int $network_id, int $server_id, $password, $selectedActions = []){try {+ $this->authorize('update', $this->resource);if (! verifyPasswordConfirmation($password, $this)) {- return;+ return 'The provided password is incorrect.';}if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) {diff --cc app/Livewire/Project/Shared/ResourceOperations.phpindex 25545c4b03,2a8747c338..9da666d8b9--- a/app/Livewire/Project/Shared/ResourceOperations.php+++ b/app/Livewire/Project/Shared/ResourceOperations.php@@@ -47,42 -56,131 +56,41 @@@ class ResourceOperations extends Componpublic function cloneTo($destination_id){- $this->authorize('update', $this->resource);+ try {+ $this->authorize('update', $this->resource);- $teamScope = fn ($q) => $q->where('team_id', currentTeam()->id);- $new_destination = StandaloneDocker::whereHas('server', $teamScope)->find($destination_id);- $new_destination = StandaloneDocker::ownedByCurrentTeam()->find($destination_id);- if (! $new_destination) {- $new_destination = SwarmDocker::ownedByCurrentTeam()->find($destination_id);- }- if (! $new_destination) {- return $this->addError('destination_id', 'Destination not found.');- }- $uuid = (string) new Cuid2;- $server = $new_destination->server;-- if ($this->resource->getMorphClass() === Application::class) {- $new_resource = clone_application($this->resource, $new_destination, ['uuid' => $uuid], $this->cloneVolumeData);-- $route = route('project.application.configuration', [- 'project_uuid' => $this->projectUuid,- 'environment_uuid' => $this->environmentUuid,- 'application_uuid' => $new_resource->uuid,- ]).'#resource-operations';-- return redirect()->to($route);- } elseif (- $this->resource->getMorphClass() === StandalonePostgresql::class ||- $this->resource->getMorphClass() === StandaloneMongodb::class ||- $this->resource->getMorphClass() === StandaloneMysql::class ||- $this->resource->getMorphClass() === StandaloneMariadb::class ||- $this->resource->getMorphClass() === StandaloneRedis::class ||- $this->resource->getMorphClass() === StandaloneKeydb::class ||- $this->resource->getMorphClass() === StandaloneDragonfly::class ||- $this->resource->getMorphClass() === StandaloneClickhouse::class- ) {- $uuid = (string) new Cuid2;- $new_resource = $this->resource->replicate([- 'id',- 'created_at',- 'updated_at',- ])->fill([- 'uuid' => $uuid,- 'name' => $this->resource->name.'-clone-'.$uuid,- 'status' => 'exited',- 'started_at' => null,- 'destination_id' => $new_destination->id,- ]);- $new_resource->save();-- $tags = $this->resource->tags;- foreach ($tags as $tag) {- $new_resource->tags()->attach($tag->id);++ $new_destination = StandaloneDocker::ownedByCurrentTeam()->find($destination_id);+ if (! $new_destination) {- $new_destination = SwarmDocker::whereHas('server', $teamScope)->find($destination_id);++ $new_destination = SwarmDocker::ownedByCurrentTeam()->find($destination_id);}-- $new_resource->persistentStorages()->delete();- $persistentVolumes = $this->resource->persistentStorages()->get();- foreach ($persistentVolumes as $volume) {- $originalName = $volume->name;- $newName = '';-- if (str_starts_with($originalName, 'postgres-data-')) {- $newName = 'postgres-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'mysql-data-')) {- $newName = 'mysql-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'redis-data-')) {- $newName = 'redis-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'clickhouse-data-')) {- $newName = 'clickhouse-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'mariadb-data-')) {- $newName = 'mariadb-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'mongodb-data-')) {- $newName = 'mongodb-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'keydb-data-')) {- $newName = 'keydb-data-'.$new_resource->uuid;- } elseif (str_starts_with($originalName, 'dragonfly-data-')) {- $newName = 'dragonfly-data-'.$new_resource->uuid;- } else {- if (str_starts_with($volume->name, $this->resource->uuid)) {- $newName = str($volume->name)->replace($this->resource->uuid, $new_resource->uuid);- } else {- $newName = $new_resource->uuid.'-'.$volume->name;- }- }-- $newPersistentVolume = $volume->replicate([- 'id',- 'created_at',- 'updated_at',- 'uuid',- ])->fill([- 'name' => $newName,- 'resource_id' => $new_resource->id,- ]);- $newPersistentVolume->save();-- if ($this->cloneVolumeData) {- try {- StopDatabase::dispatch($this->resource);- $sourceVolume = $volume->name;- $targetVolume = $newPersistentVolume->name;- $sourceServer = $this->resource->destination->server;- $targetServer = $new_resource->destination->server;-- VolumeCloneJob::dispatch($sourceVolume, $targetVolume, $sourceServer, $targetServer, $newPersistentVolume);-- StartDatabase::dispatch($this->resource);- } catch (\Exception $e) {- \Log::error('Failed to copy volume data for '.$volume->name.': '.$e->getMessage());- }- }+ if (! $new_destination) {+ return $this->addError('destination_id', 'Destination not found.');}+ $uuid = (string) new Cuid2;+ $server = $new_destination->server;- if ($this->resource->getMorphClass() === \App\Models\Application::class) {- $fileStorages = $this->resource->fileStorages()->get();- foreach ($fileStorages as $storage) {- $newStorage = $storage->replicate([- 'id',- 'created_at',- 'updated_at',- ])->fill([- 'resource_id' => $new_resource->id,- ]);- $newStorage->save();- }++ if ($this->resource->getMorphClass() === Application::class) {+ $new_resource = clone_application($this->resource, $new_destination, ['uuid' => $uuid], $this->cloneVolumeData);++ $route = route('project.application.configuration', [+ 'project_uuid' => $this->projectUuid,+ 'environment_uuid' => $this->environmentUuid,+ 'application_uuid' => $new_resource->uuid,+ ]).'#resource-operations';- $scheduledBackups = $this->resource->scheduledBackups()->get();- foreach ($scheduledBackups as $backup) {+ return redirect()->to($route);+ } elseif (- $this->resource->getMorphClass() === \App\Models\StandalonePostgresql::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneMongodb::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneMysql::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneMariadb::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneRedis::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneKeydb::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneDragonfly::class ||- $this->resource->getMorphClass() === \App\Models\StandaloneClickhouse::class++ $this->resource->getMorphClass() === StandalonePostgresql::class ||++ $this->resource->getMorphClass() === StandaloneMongodb::class ||++ $this->resource->getMorphClass() === StandaloneMysql::class ||++ $this->resource->getMorphClass() === StandaloneMariadb::class ||++ $this->resource->getMorphClass() === StandaloneRedis::class ||++ $this->resource->getMorphClass() === StandaloneKeydb::class ||++ $this->resource->getMorphClass() === StandaloneDragonfly::class ||++ $this->resource->getMorphClass() === StandaloneClickhouse::class+ ) {$uuid = (string) new Cuid2;- $newBackup = $backup->replicate([+ $new_resource = $this->resource->replicate(['id','created_at','updated_at',@@@ -134,9 -280,10 +142,10 @@@'id','created_at','updated_at',+ 'uuid',])->fill(['name' => $newName,- 'resource_id' => $application->id,+ 'resource_id' => $new_resource->id,]);$newPersistentVolume->save();@@@ -156,200 -303,60 +165,202 @@@}}}- }- foreach ($new_resource->databases() as $database) {- $database->fill([- 'status' => 'exited',- ])->save();+ $fileStorages = $this->resource->fileStorages()->get();+ foreach ($fileStorages as $storage) {+ $newStorage = $storage->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'resource_id' => $new_resource->id,+ ]);+ $newStorage->save();+ }- $persistentVolumes = $database->persistentStorages()->get();- foreach ($persistentVolumes as $volume) {- $newName = '';- if (str_starts_with($volume->name, $volume->resource->uuid)) {- $newName = str($volume->name)->replace($volume->resource->uuid, $database->uuid);- } else {- $newName = $database->uuid.'-'.str($volume->name)->afterLast('-');- }+ $scheduledBackups = $this->resource->scheduledBackups()->get();+ foreach ($scheduledBackups as $backup) {+ $uuid = (string) new Cuid2;+ $newBackup = $backup->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'uuid' => $uuid,+ 'database_id' => $new_resource->id,+ 'database_type' => $new_resource->getMorphClass(),+ 'team_id' => currentTeam()->id,+ ]);+ $newBackup->save();+ }- $newPersistentVolume = $volume->replicate([+ $environmentVaribles = $this->resource->environment_variables()->get();+ foreach ($environmentVaribles as $environmentVarible) {+ $payload = [+ 'resourceable_id' => $new_resource->id,+ 'resourceable_type' => $new_resource->getMorphClass(),+ ];+ $newEnvironmentVariable = $environmentVarible->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill($payload);+ $newEnvironmentVariable->save();+ }++ $route = route('project.database.configuration', [+ 'project_uuid' => $this->projectUuid,+ 'environment_uuid' => $this->environmentUuid,+ 'database_uuid' => $new_resource->uuid,+ ]).'#resource-operations';++ return redirect()->to($route);+ } elseif ($this->resource->type() === 'service') {+ $uuid = (string) new Cuid2;+ $new_resource = $this->resource->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'uuid' => $uuid,+ 'name' => $this->resource->name.'-clone-'.$uuid,+ 'destination_id' => $new_destination->id,+ 'destination_type' => $new_destination->getMorphClass(),- 'server_id' => $new_destination->server_id, // server_id is probably not needed anymore because of the new polymorphic relationships (here it is needed for clone to a different server to work - but maybe we can drop the column)++ 'server_id' => $new_destination->server_id,+ ]);++ $new_resource->save();++ $tags = $this->resource->tags;+ foreach ($tags as $tag) {+ $new_resource->tags()->attach($tag->id);+ }++ $scheduledTasks = $this->resource->scheduled_tasks()->get();+ foreach ($scheduledTasks as $task) {+ $newTask = $task->replicate(['id','created_at','updated_at',- 'uuid',])->fill([- 'name' => $newName,- 'resource_id' => $database->id,+ 'uuid' => (string) new Cuid2,+ 'service_id' => $new_resource->id,+ 'team_id' => currentTeam()->id,]);- $newPersistentVolume->save();+ $newTask->save();+ }- if ($this->cloneVolumeData) {- try {- StopService::dispatch($database->service);- $sourceVolume = $volume->name;- $targetVolume = $newPersistentVolume->name;- $sourceServer = $database->service->destination->server;- $targetServer = $new_resource->destination->server;+ $environmentVariables = $this->resource->environment_variables()->get();+ foreach ($environmentVariables as $environmentVariable) {+ $newEnvironmentVariable = $environmentVariable->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'resourceable_id' => $new_resource->id,+ 'resourceable_type' => $new_resource->getMorphClass(),+ ]);+ $newEnvironmentVariable->save();+ }- VolumeCloneJob::dispatch($sourceVolume, $targetVolume, $sourceServer, $targetServer, $newPersistentVolume);+ foreach ($new_resource->applications() as $application) {- $application->update([++ $application->fill([+ 'status' => 'exited',- ]);++ ])->save();++ $persistentVolumes = $application->persistentStorages()->get();+ foreach ($persistentVolumes as $volume) {+ $newName = '';+ if (str_starts_with($volume->name, $volume->resource->uuid)) {+ $newName = str($volume->name)->replace($volume->resource->uuid, $application->uuid);+ } else {+ $newName = $application->uuid.'-'.str($volume->name)->afterLast('-');+ }- StartService::dispatch($database->service);- } catch (\Exception $e) {- \Log::error('Failed to copy volume data for '.$volume->name.': '.$e->getMessage());+ $newPersistentVolume = $volume->replicate([+ 'id',+ 'created_at',+ 'updated_at',++ 'uuid',+ ])->fill([+ 'name' => $newName,+ 'resource_id' => $application->id,+ ]);+ $newPersistentVolume->save();++ if ($this->cloneVolumeData) {+ try {+ StopService::dispatch($application);+ $sourceVolume = $volume->name;+ $targetVolume = $newPersistentVolume->name;+ $sourceServer = $application->service->destination->server;+ $targetServer = $new_resource->destination->server;++ VolumeCloneJob::dispatch($sourceVolume, $targetVolume, $sourceServer, $targetServer, $newPersistentVolume);++ StartService::dispatch($application);+ } catch (\Exception $e) {+ \Log::error('Failed to copy volume data for '.$volume->name.': '.$e->getMessage());+ }}}}- }- $new_resource->parse();+ foreach ($new_resource->databases() as $database) {- $database->update([++ $database->fill([+ 'status' => 'exited',- ]);++ ])->save();++ $persistentVolumes = $database->persistentStorages()->get();+ foreach ($persistentVolumes as $volume) {+ $newName = '';+ if (str_starts_with($volume->name, $volume->resource->uuid)) {+ $newName = str($volume->name)->replace($volume->resource->uuid, $database->uuid);+ } else {+ $newName = $database->uuid.'-'.str($volume->name)->afterLast('-');+ }- $route = route('project.service.configuration', [- 'project_uuid' => $this->projectUuid,- 'environment_uuid' => $this->environmentUuid,- 'service_uuid' => $new_resource->uuid,- ]).'#resource-operations';+ $newPersistentVolume = $volume->replicate([+ 'id',+ 'created_at',+ 'updated_at',++ 'uuid',+ ])->fill([+ 'name' => $newName,+ 'resource_id' => $database->id,+ ]);+ $newPersistentVolume->save();++ if ($this->cloneVolumeData) {+ try {+ StopService::dispatch($database->service);+ $sourceVolume = $volume->name;+ $targetVolume = $newPersistentVolume->name;+ $sourceServer = $database->service->destination->server;+ $targetServer = $new_resource->destination->server;++ VolumeCloneJob::dispatch($sourceVolume, $targetVolume, $sourceServer, $targetServer, $newPersistentVolume);++ StartService::dispatch($database->service);+ } catch (\Exception $e) {+ \Log::error('Failed to copy volume data for '.$volume->name.': '.$e->getMessage());+ }+ }+ }+ }- return redirect()->to($route);+ $new_resource->parse();++ $route = route('project.service.configuration', [+ 'project_uuid' => $this->projectUuid,+ 'environment_uuid' => $this->environmentUuid,+ 'service_uuid' => $new_resource->uuid,+ ]).'#resource-operations';++ return redirect()->to($route);+ }+ } catch (\Throwable $e) {+ return handleError($e, $this);}}diff --cc app/Livewire/Server/Resources.phpindex 31e57b3016,3710064dc8..9ea87161d8--- a/app/Livewire/Server/Resources.php+++ b/app/Livewire/Server/Resources.php@@@ -29,38 -30,38 +30,53 @@@ class Resources extends Componenpublic function startUnmanaged($id){- if (! ValidationPatterns::isValidContainerName($id)) {- $this->dispatch('error', 'Invalid container identifier.');-- return;+ try {+ $this->authorize('update', $this->server);++ if (! ValidationPatterns::isValidContainerName($id)) {++ $this->dispatch('error', 'Invalid container identifier.');++++ return;++ }+ $this->server->startUnmanaged($id);+ $this->dispatch('success', 'Container started.');+ $this->loadUnmanagedContainers();+ } catch (\Throwable $e) {+ return handleError($e, $this);}- $this->server->startUnmanaged($id);- $this->dispatch('success', 'Container started.');- $this->loadUnmanagedContainers();}public function restartUnmanaged($id){- if (! ValidationPatterns::isValidContainerName($id)) {- $this->dispatch('error', 'Invalid container identifier.');-- return;+ try {+ $this->authorize('update', $this->server);++ if (! ValidationPatterns::isValidContainerName($id)) {++ $this->dispatch('error', 'Invalid container identifier.');++++ return;++ }+ $this->server->restartUnmanaged($id);+ $this->dispatch('success', 'Container restarted.');+ $this->loadUnmanagedContainers();+ } catch (\Throwable $e) {+ return handleError($e, $this);}- $this->server->restartUnmanaged($id);- $this->dispatch('success', 'Container restarted.');- $this->loadUnmanagedContainers();}public function stopUnmanaged($id){- if (! ValidationPatterns::isValidContainerName($id)) {- $this->dispatch('error', 'Invalid container identifier.');-- return;+ try {+ $this->authorize('update', $this->server);++ if (! ValidationPatterns::isValidContainerName($id)) {++ $this->dispatch('error', 'Invalid container identifier.');++++ return;++ }+ $this->server->stopUnmanaged($id);+ $this->dispatch('success', 'Container stopped.');+ $this->loadUnmanagedContainers();+ } catch (\Throwable $e) {+ return handleError($e, $this);}- $this->server->stopUnmanaged($id);- $this->dispatch('success', 'Container stopped.');- $this->loadUnmanagedContainers();}public function refreshStatus()diff --cc app/Livewire/Server/ValidateAndInstall.phpindex 9b0f025739,59ca4cd365..afcc918a65--- a/app/Livewire/Server/ValidateAndInstall.php+++ b/app/Livewire/Server/ValidateAndInstall.php@@@ -90,21 -86,18 +90,22 @@@ class ValidateAndInstall extends Componpublic function validateConnection(){- $this->authorize('update', $this->server);- ['uptime' => $this->uptime, 'error' => $error] = $this->server->validateConnection();- if (! $this->uptime) {- $sanitizedError = htmlspecialchars($error ?? '', ENT_QUOTES, 'UTF-8');- $this->error = 'Server is not reachable. Please validate your configuration and connection.<br>Check this <a target="_blank" class="text-black underline dark:text-white" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help. <br><br><div class="text-error">Error: '.$sanitizedError.'</div>';- $this->server->update([- 'validation_logs' => $this->error,- ]);-- return;+ try {+ $this->authorize('update', $this->server);+ ['uptime' => $this->uptime, 'error' => $error] = $this->server->validateConnection();+ if (! $this->uptime) {- $this->error = 'Server is not reachable. Please validate your configuration and connection.<br>Check this <a target="_blank" class="text-black underline dark:text-white" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help. <br><br><div class="text-error">Error: '.$error.'</div>';++ $sanitizedError = htmlspecialchars($error ?? '', ENT_QUOTES, 'UTF-8');++ $this->error = 'Server is not reachable. Please validate your configuration and connection.<br>Check this <a target="_blank" class="text-black underline dark:text-white" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help. <br><br><div class="text-error">Error: '.$sanitizedError.'</div>';+ $this->server->update([+ 'validation_logs' => $this->error,+ ]);++ return;+ }+ $this->dispatch('validateOS');+ } catch (\Throwable $e) {+ return handleError($e, $this);}- $this->dispatch('validateOS');}public function validateOS()diff --cc app/Livewire/Settings/Advanced.phpindex c63e9b2f75,d31f688593..6f6815b1f5--- a/app/Livewire/Settings/Advanced.php+++ b/app/Livewire/Settings/Advanced.php@@@ -3,8 -3,8 +3,9 @@@namespace App\Livewire\Settings;use App\Models\InstanceSettings;+ use App\Rules\ValidDnsServers;use App\Rules\ValidIpOrCidr;+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Livewire\Attributes\Validate;use Livewire\Component;@@@ -162,9 -157,21 +162,22 @@@ class Advanced extends Componen}}+ public function toggleRegistration($password): bool+ {+ if (! verifyPasswordConfirmation($password, $this)) {+ return false;+ }++ $this->settings->is_registration_enabled = $this->is_registration_enabled = true;+ $this->settings->save();+ $this->dispatch('success', 'Registration has been enabled.');++ return true;+ }+public function toggleTwoStepConfirmation($password): bool{+ $this->authorize('update', $this->settings);if (! verifyPasswordConfirmation($password, $this)) {return false;}diff --cc app/Livewire/SettingsBackup.phpindex cfd188b403,5336c0c9aa..d5d80acbd2--- a/app/Livewire/SettingsBackup.php+++ b/app/Livewire/SettingsBackup.php@@@ -6,8 -6,8 +6,9 @@@ use App\Models\InstanceSettingsuse App\Models\S3Storage;use App\Models\ScheduledDatabaseBackup;use App\Models\Server;+ use App\Models\StandaloneDocker;use App\Models\StandalonePostgresql;+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Livewire\Attributes\Locked;use Livewire\Attributes\Validate;use Livewire\Component;diff --cc app/Livewire/Storage/Show.phpindex fd8c122922,dc5121e945..93c1ff2e4a--- a/app/Livewire/Storage/Show.php+++ b/app/Livewire/Storage/Show.php@@@ -18,11 -23,22 +23,26 @@@ class Show extends Componenif (! $this->storage) {abort(404);}- $this->authorize('view', $this->storage);+ try {+ $this->authorize('view', $this->storage);+ } catch (\Illuminate\Auth\Access\AuthorizationException) {+ return $this->redirectRoute('storage.index', navigate: true);+ }+ $this->currentRoute = request()->route()->getName();+ $this->backupCount = ScheduledDatabaseBackup::where('s3_storage_id', $this->storage->id)->count();+ }++ public function delete()+ {+ try {+ $this->authorize('delete', $this->storage);++ $this->storage->delete();++ return redirect()->route('storage.index');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }}public function render()diff --cc bootstrap/helpers/api.phpindex edb1e59a10,8088e6b99f..4b76200d2c--- a/bootstrap/helpers/api.php+++ b/bootstrap/helpers/api.php@@@ -134,13 -136,15 +136,15 @@@ function sharedDataApplications('manual_webhook_secret_gitlab' => 'string|nullable','manual_webhook_secret_bitbucket' => 'string|nullable','manual_webhook_secret_gitea' => 'string|nullable',- 'dockerfile_location' => ['string', 'nullable', 'max:255', 'regex:/^\/[a-zA-Z0-9._\-\/]+$/'],- 'docker_compose_location' => ['string', 'nullable', 'max:255', 'regex:/^\/[a-zA-Z0-9._\-\/]+$/'],+ 'dockerfile_location' => \App\Support\ValidationPatterns::filePathRules(),+ 'dockerfile_target_build' => \App\Support\ValidationPatterns::dockerTargetRules(),+ 'docker_compose_location' => \App\Support\ValidationPatterns::filePathRules(),'docker_compose' => 'string|nullable','docker_compose_domains' => 'array|nullable',- 'docker_compose_custom_start_command' => 'string|nullable',- 'docker_compose_custom_build_command' => 'string|nullable',+ 'docker_compose_custom_start_command' => \App\Support\ValidationPatterns::shellSafeCommandRules(),+ 'docker_compose_custom_build_command' => \App\Support\ValidationPatterns::shellSafeCommandRules(),'is_container_label_escape_enabled' => 'boolean',- 'is_preserve_repository_enabled' => 'boolean'++ 'is_preserve_repository_enabled' => 'boolean',];}diff --cc bootstrap/helpers/proxy.phpindex ac52c0af8c,ed18dfe760..d443c84a4b--- a/bootstrap/helpers/proxy.php+++ b/bootstrap/helpers/proxy.php@@@ -108,18 -109,20 +109,22 @@@ function connectProxyToNetworks(Server['networks' => $networks] = collectDockerNetworksByServer($server);if ($server->isSwarm()) {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --driver overlay --attachable $network >/dev/null",- "docker network connect $network coolify-proxy >/dev/null 2>&1 || true",- "echo 'Successfully connected coolify-proxy to $network network.'",+ "docker network ls --format '{{.Name}}' | grep '^{$network}$' >/dev/null || docker network create --driver overlay --attachable {$safe} >/dev/null",+ "docker network connect {$safe} coolify-proxy >/dev/null 2>&1 || true",+ "echo 'Successfully connected coolify-proxy to {$safe} network.'",];});} else {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --attachable $network >/dev/null",- "docker network connect $network coolify-proxy >/dev/null 2>&1 || true",- "echo 'Successfully connected coolify-proxy to $network network.'",+ "docker network ls --format '{{.Name}}' | grep '^{$network}$' >/dev/null || docker network create --attachable {$safe} >/dev/null",+ "docker network connect {$safe} coolify-proxy >/dev/null 2>&1 || true",+ "echo 'Successfully connected coolify-proxy to {$safe} network.'",];});}@@@ -140,16 -143,18 +145,20 @@@ function ensureProxyNetworksExist(Serveif ($server->isSwarm()) {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "echo 'Ensuring network $network exists...'",- "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --driver overlay --attachable $network",+ "echo 'Ensuring network {$safe} exists...'",+ "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --driver overlay --attachable {$safe}",];});} else {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "echo 'Ensuring network $network exists...'",- "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --attachable $network",+ "echo 'Ensuring network {$safe} exists...'",+ "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --attachable {$safe}",];});}diff --cc resources/views/livewire/dashboard.blade.phpindex 8c75fd102b,26a404b17d..19d8196137--- a/resources/views/livewire/dashboard.blade.php+++ b/resources/views/livewire/dashboard.blade.php@@@ -11,23 -11,20 +11,23 @@@<section class="-mt-2"><div class="flex items-center gap-2 pb-2"><h3>Projects</h3>- @can('create', App\Models\Project::class)- @if ($projects->count() > 0)- <x-modal-input buttonTitle="Add" title="New Project">- <x-slot:content>- <button- class="flex items-center justify-center size-4 text-black dark:text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">- <svg class="size-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"- stroke-width="2" stroke="currentColor">- <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />- </svg>- </button>- </x-slot:content>- <livewire:project.add-empty />- </x-modal-input>- @endif++@can('create', App\Models\Project::class)+ @if ($projects->count() > 0)+ <x-modal-input buttonTitle="Add" title="New Project">+ <x-slot:content>+ <button- class="flex items-center justify-center size-4 text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">++ class="flex items-center justify-center size-4 text-black dark:text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">+ <svg class="size-3" xmlns="http://www.w3.org/2000/svg" fill="none"+ viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">+ <path stroke-linecap="round" stroke-linejoin="round"+ d="M12 4.5v15m7.5-7.5h-15" />+ </svg>+ </button>+ </x-slot:content>+ <livewire:project.add-empty />+ </x-modal-input>+ @endif+ @endcan</div>@if ($projects->count() > 0)<div class="grid grid-cols-1 gap-4 xl:grid-cols-2">@@@ -83,23 -77,20 +83,23 @@@<section><div class="flex items-center gap-2 pb-2"><h3>Servers</h3>- @can('create', App\Models\Server::class)- @if ($servers->count() > 0 && $privateKeys->count() > 0)- <x-modal-input buttonTitle="Add" title="New Server" :closeOutside="false">- <x-slot:content>- <button- class="flex items-center justify-center size-4 text-black dark:text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">- <svg class="size-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"- stroke-width="2" stroke="currentColor">- <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />- </svg>- </button>- </x-slot:content>- <livewire:server.create />- </x-modal-input>- @endif++@can('create', App\Models\Server::class)+ @if ($servers->count() > 0 && $privateKeys->count() > 0)+ <x-modal-input buttonTitle="Add" title="New Server" :closeOutside="false">+ <x-slot:content>+ <button- class="flex items-center justify-center size-4 text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">++ class="flex items-center justify-center size-4 text-black dark:text-white rounded hover:bg-coolgray-400 dark:hover:bg-coolgray-300 cursor-pointer">+ <svg class="size-3" xmlns="http://www.w3.org/2000/svg" fill="none"+ viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">+ <path stroke-linecap="round" stroke-linejoin="round"+ d="M12 4.5v15m7.5-7.5h-15" />+ </svg>+ </button>+ </x-slot:content>+ <livewire:server.create />+ </x-modal-input>+ @endif+ @endcan</div>@if ($servers->count() > 0)<div class="grid grid-cols-1 gap-4 xl:grid-cols-2">diff --cc resources/views/livewire/project/database/heading.blade.phpindex 890323102e,89a64b0e13..03bbd1e5e4--- a/resources/views/livewire/project/database/heading.blade.php+++ b/resources/views/livewire/project/database/heading.blade.php@@@ -38,9 -38,48 +38,48 @@@@endif</nav>@if ($database->destination->server->isFunctional())- <div class="flex flex-wrap gap-2 items-center">+ <div class="flex flex-wrap gap-2 items-center">+ <div class="md:hidden">+ <x-dropdown>+ <x-slot:title>+ Actions+ </x-slot>+ @if (!str($database->status)->startsWith('exited'))+ <x-modal-confirmation title="Confirm Database Restart?" buttonTitle="Restart" submitAction="restart"+ :actions="[+ 'This database will be unavailable during the restart.',+ 'If the database is currently in use data could be lost.',+ ]" :confirmWithText="false" :confirmWithPassword="false" step2ButtonText="Restart Database"+ :dispatchEvent="true" dispatchEventType="restartEvent">+ <x-slot:trigger>+ <div class="dropdown-item dropdown-item-touch">+ Restart+ </div>+ </x-slot:trigger>+ </x-modal-confirmation>+ <x-modal-confirmation title="Confirm Database Stopping?" buttonTitle="Stop" submitAction="stop"+ :checkboxes="$checkboxes" :actions="[+ 'This database will be stopped.',+ 'If the database is currently in use data could be lost.',+ 'All non-persistent data of this database (containers, networks, unused images) will be deleted (don\'t worry, no data is lost and you can start the database again).',+ ]" :confirmWithText="false" :confirmWithPassword="false"+ step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:trigger>+ <div class="dropdown-item dropdown-item-touch text-error">+ Stop+ </div>+ </x-slot:trigger>+ </x-modal-confirmation>+ @else+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('startEvent')">+ Start+ </div>+ @endif+ </x-dropdown>+ </div>+ <div class="hidden flex-wrap items-center gap-2 md:flex">@if (!str($database->status)->startsWith('exited'))- <x-modal-confirmation title="Confirm Database Restart?" buttonTitle="Restart" submitAction="restart"+ <x-modal-confirmation :disabled="!auth()->user()->can('manage', $database)" :authDisabled="!auth()->user()->can('manage', $database)" title="Confirm Database Restart?" buttonTitle="Restart" submitAction="restart":actions="['This database will be unavailable during the restart.','If the database is currently in use data could be lost.',@@@ -88,20 -127,23 +127,23 @@@<path d="M7 4v16l13 -8z" /></svg>Start- </button>+ </x-forms.button>@endif- @script- <script>- $wire.$on('startEvent', () => {- $wire.$call('start');- });- $wire.$on('restartEvent', () => {- $wire.$dispatch('info', 'Restarting database.');- $wire.$call('restart');- });- </script>- @endscript</div>+ @script+ <script>+ $wire.$on('startEvent', () => {+ window.dispatchEvent(new CustomEvent('startdatabase'));+ $wire.$call('start');+ });+ $wire.$on('restartEvent', () => {+ $wire.$dispatch('info', 'Restarting database.');+ window.dispatchEvent(new CustomEvent('startdatabase'));+ $wire.$call('restart');+ });+ </script>+ @endscript+ </div>@else<div class="text-error">Underlying server is not functional.</div>@endifdiff --cc resources/views/livewire/project/service/heading.blade.phpindex db21f33176,264a96e9c0..fdcb1e2813--- a/resources/views/livewire/project/service/heading.blade.php+++ b/resources/views/livewire/project/service/heading.blade.php@@@ -24,105 -25,182 +25,182 @@@<button>Terminal</button></a>@endcan- <x-services.links :service="$service" />+ <div class="shrink-0">+ <x-services.links :service="$service" />+ </div></nav>@if ($service->isDeployable)- <div class="flex flex-wrap order-first gap-2 items-center sm:order-last">- <x-services.advanced :service="$service" />- @if (str($service->status)->contains('running'))- <x-forms.button canGate="deploy" :canResource="$service" title="Restart" @click="$wire.dispatch('restartEvent')">- <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">- <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"- stroke-width="2">- <path d="M19.933 13.041 a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />- <path d="M20 4v5h-5" />- </g>- </svg>- Restart- </x-forms.button>- <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"- submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"- :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">- <x-slot:button-title>- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"- stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"- stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>- <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>- <path- d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>+ <div class="order-first flex flex-wrap items-center gap-2 sm:order-last">+ <div class="md:hidden">+ <x-dropdown>+ <x-slot:title>+ Actions+ </x-slot>+ @if (str($service->status)->contains('running'))+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('restartEvent')">+ Restart+ </div>+ <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:trigger>+ <div class="dropdown-item dropdown-item-touch text-error">+ Stop+ </div>+ </x-slot:trigger>+ </x-modal-confirmation>+ <div class="mx-2 my-1 border-t border-neutral-200 dark:border-coolgray-300"></div>+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('pullAndRestartEvent')">+ Pull Latest Images & Restart+ </div>+ @elseif (str($service->status)->contains('degraded'))+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('restartEvent')">+ Restart+ </div>+ <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:trigger>+ <div class="dropdown-item dropdown-item-touch text-error">+ Stop+ </div>+ </x-slot:trigger>+ </x-modal-confirmation>+ <div class="mx-2 my-1 border-t border-neutral-200 dark:border-coolgray-300"></div>+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('forceDeployEvent')">+ Force Restart+ </div>+ @elseif (str($service->status)->contains('exited'))+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('startEvent')">+ Deploy+ </div>+ <div class="mx-2 my-1 border-t border-neutral-200 dark:border-coolgray-300"></div>+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('forceDeployEvent')">+ Force Deploy+ </div>+ <div class="dropdown-item dropdown-item-touch" wire:click='stop(true)'>+ Force Cleanup Containers+ </div>+ @else+ <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:trigger>+ <div class="dropdown-item dropdown-item-touch text-error">+ Stop+ </div>+ </x-slot:trigger>+ </x-modal-confirmation>+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('startEvent')">+ Deploy+ </div>+ <div class="mx-2 my-1 border-t border-neutral-200 dark:border-coolgray-300"></div>+ <div class="dropdown-item dropdown-item-touch" @click="$wire.dispatch('forceDeployEvent')">+ Force Deploy+ </div>+ <div class="dropdown-item dropdown-item-touch" wire:click='stop(true)'>+ Force Cleanup Containers+ </div>+ @endif+ </x-dropdown>+ </div>+ <div class="hidden flex-wrap items-center gap-2 md:flex">+ <x-services.advanced :service="$service" />+ @if (str($service->status)->contains('running'))- <x-forms.button title="Restart" @click="$wire.dispatch('restartEvent')">++ <x-forms.button canGate="deploy" :canResource="$service" title="Restart" @click="$wire.dispatch('restartEvent')">+ <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"+ stroke-width="2">+ <path d="M19.933 13.041 a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />+ <path d="M20 4v5h-5" />+ </g>+ </svg>+ Restart+ </x-forms.button>- <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"++ <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:button-title>+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"+ stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>+ <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ <path+ d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ </svg>+ Stop+ </x-slot:button-title>+ </x-modal-confirmation>+ @elseif (str($service->status)->contains('degraded'))- <x-forms.button title="Restart" @click="$wire.dispatch('restartEvent')">++ <x-forms.button canGate="deploy" :canResource="$service" title="Restart" @click="$wire.dispatch('restartEvent')">+ <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"+ stroke-width="2">+ <path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />+ <path d="M20 4v5h-5" />+ </g></svg>- Stop- </x-slot:button-title>- </x-modal-confirmation>- @elseif (str($service->status)->contains('degraded'))- <x-forms.button canGate="deploy" :canResource="$service" title="Restart" @click="$wire.dispatch('restartEvent')">- <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">- <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"- stroke-width="2">- <path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />- <path d="M20 4v5h-5" />- </g>- </svg>- Restart- </x-forms.button>- <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"- submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"- :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">- <x-slot:button-title>- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"- stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"+ Restart+ </x-forms.button>- <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"++ <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:button-title>+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"+ stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>+ <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ <path+ d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ </svg>+ Stop+ </x-slot:button-title>+ </x-modal-confirmation>+ @elseif (str($service->status)->contains('exited'))- <button @click="$wire.dispatch('startEvent')" class="gap-2 button">++ <x-forms.button canGate="deploy" :canResource="$service" @click="$wire.dispatch('startEvent')" class="gap-2">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>- <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>- <path- d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M7 4v16l13 -8z" /></svg>- Stop- </x-slot:button-title>- </x-modal-confirmation>- @elseif (str($service->status)->contains('exited'))- <x-forms.button canGate="deploy" :canResource="$service" @click="$wire.dispatch('startEvent')" class="gap-2">- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24"- stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"- stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M7 4v16l13 -8z" />- </svg>- Deploy- </x-forms.button>- @else- <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"- submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"- :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">- <x-slot:button-title>- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"- stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"+ Deploy- </button>++ </x-forms.button>+ @else- <x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"++ <x-modal-confirmation :disabled="!auth()->user()->can('stop', $service)" :authDisabled="!auth()->user()->can('stop', $service)" title="Confirm Service Stopping?" buttonTitle="Stop" :dispatchEvent="true"+ submitAction="stop" dispatchEventType="stopEvent" :checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]"+ :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue" step2ButtonText="Confirm">+ <x-slot:button-title>+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"+ stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>+ <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ <path+ d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">+ </path>+ </svg>+ Stop+ </x-slot:button-title>+ </x-modal-confirmation>- <button @click="$wire.dispatch('startEvent')" class="gap-2 button">++ <x-forms.button canGate="deploy" :canResource="$service" @click="$wire.dispatch('startEvent')" class="gap-2">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>- <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>- <path- d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">- </path>+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M7 4v16l13 -8z" /></svg>- Stop- </x-slot:button-title>- </x-modal-confirmation>- <x-forms.button canGate="deploy" :canResource="$service" @click="$wire.dispatch('startEvent')" class="gap-2">- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24"- stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"- stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M7 4v16l13 -8z" />- </svg>- Deploy- </x-forms.button>- @endif+ Deploy- </button>++ </x-forms.button>+ @endif+ </div></div>@else<div class="flex flex-wrap order-first gap-2 items-center sm:order-last">diff --cc resources/views/livewire/project/shared/environment-variable/show.blade.phpindex 9ca92602c9,6630d0500c..1753f3f82b--- a/resources/views/livewire/project/shared/environment-variable/show.blade.php+++ b/resources/views/livewire/project/shared/environment-variable/show.blade.php@@@ -171,38 -183,29 +183,37 @@@type="password" id="real_value" />@endif</div>- @if (!$isMagicVariable)- <x-forms.input instantSave id="comment" label="Comment"- helper="Add a note to document what this environment variable is used for." maxlength="256" />- @endif+ <x-forms.input instantSave id="comment" label="Comment"++ placeholder="{{ $isMagicVariable ? 'This env cannot be edited manually, it is handled by Coolify.' : '' }}"+ helper="Add a note to document what this environment variable is used for." maxlength="256" /></div>@endif@else<div class="flex flex-col w-full gap-2"><div class="flex flex-col w-full gap-2 lg:flex-row"><x-forms.input disabled id="key" />- <x-forms.env-var-input- disabled- type="password"- id="value"- :availableVars="$isSharedVariable ? [] : $this->availableSharedVariables"- :projectUuid="data_get($parameters, 'project_uuid')"- :environmentUuid="data_get($parameters, 'environment_uuid')"- :serverUuid="data_get($parameters, 'server_uuid')" />- @if ($is_shared)- <x-forms.input disabled type="password" id="real_value" />+ @if ($isValueHidden)+ <div class="w-full">+ <input disabled type="text" value="Hidden (only admins can view)"+ class="input italic !text-neutral-500 dark:!text-neutral-500" />+ </div>+ @else+ <x-forms.env-var-input+ disabled+ type="password"+ id="value"- :availableVars="$this->availableSharedVariables"++ :availableVars="$isSharedVariable ? [] : $this->availableSharedVariables"+ :projectUuid="data_get($parameters, 'project_uuid')"- :environmentUuid="data_get($parameters, 'environment_uuid')" />++ :environmentUuid="data_get($parameters, 'environment_uuid')"++ :serverUuid="data_get($parameters, 'server_uuid')" />+ @if ($is_shared)+ <x-forms.input disabled type="password" id="real_value" />+ @endif@endif</div>- @if (!$isMagicVariable)- <x-forms.input disabled id="comment" label="Comment"- helper="Add a note to document what this environment variable is used for." maxlength="256" />- @endif+ <x-forms.input disabled id="comment" label="Comment"+ placeholder="{{ $isMagicVariable ? 'This env cannot be edited manually, it is handled by Coolify.' : '' }}"+ helper="Add a note to document what this environment variable is used for." maxlength="256" /></div>@endcan@can('update', $this->env)diff --cc resources/views/livewire/project/shared/scheduled-task/show.blade.phpindex 6777e96a03,c699609c02..79e0f26047--- a/resources/views/livewire/project/shared/scheduled-task/show.blade.php+++ b/resources/views/livewire/project/shared/scheduled-task/show.blade.php@@@ -2,50 -2,36 +2,39 @@@<form wire:submit="submit" class="w-full"><div class="flex flex-col gap-2 pb-2"><div class="flex gap-2 items-end">- <h2>Scheduled Task</h2>+ <h2>Task {{ $task->name }}</h2>- <x-forms.button type="submit">+ <x-forms.button canGate="update" :canResource="$resource" type="submit">Save</x-forms.button>@if ($resource->isRunning())- <x-forms.button type="button" wire:click="executeNow">- Execute Now- </x-forms.button>+ @can('update', $resource)+ <x-forms.button type="button" wire:click="executeNow">+ Execute Now+ </x-forms.button>+ @endcan@endif- @if (!$isEnabled)- <x-forms.button wire:click="toggleEnabled" isHighlighted>Enable Task</x-forms.button>- @else- <x-forms.button wire:click="toggleEnabled">Disable Task</x-forms.button>- @endif- <x-modal-confirmation title="Confirm Scheduled Task Deletion?" isErrorButton buttonTitle="Delete"- submitAction="delete({{ $task->id }})" :actions="['The selected scheduled task will be permanently deleted.']" confirmationText="{{ $task->name }}"- confirmationLabel="Please confirm the execution of the actions by entering the Scheduled Task Name below"- shortConfirmationLabel="Scheduled Task Name" :confirmWithPassword="false"- step2ButtonText="Permanently Delete" />-+ @can('update', $resource)++ @if (!$isEnabled)++ <x-forms.button wire:click="toggleEnabled" isHighlighted>Enable Task</x-forms.button>++ @else++ <x-forms.button wire:click="toggleEnabled">Disable Task</x-forms.button>++ @endif+ <x-modal-confirmation title="Confirm Scheduled Task Deletion?" isErrorButton buttonTitle="Delete"+ submitAction="delete({{ $task->id }})" :actions="['The selected scheduled task will be permanently deleted.']" confirmationText="{{ $task->name }}"+ confirmationLabel="Please confirm the execution of the actions by entering the Scheduled Task Name below"+ shortConfirmationLabel="Scheduled Task Name" :confirmWithPassword="false"+ step2ButtonText="Permanently Delete" />+ @endcan</div>- <div class="w-48">- @can('update', $resource)- <x-forms.checkbox instantSave id="isEnabled" label="Enabled" />- @else- <x-forms.checkbox disabled id="isEnabled" label="Enabled" />- @endcan- </div>+ <h3 class="pt-4">Configuration</h3><div class="flex gap-2 w-full">- <x-forms.input placeholder="Name" id="name" label="Name" required />- <x-forms.input placeholder="0 0 * * * or daily" id="frequency" label="Frequency"+ <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="Name" id="name" label="Name" required />- <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="php artisan schedule:run" id="command" label="Command" required />- <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="0 0 * * * or daily" id="frequency" label="Frequency" required />++ <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="0 0 * * * or daily" id="frequency" label="Frequency"+ helper="You can use every_minute, hourly, daily, weekly, monthly, yearly or a cron expression." required />- <x-forms.input type="number" placeholder="300" id="timeout"+ <x-forms.input :disabled="!auth()->user()->can('update', $resource)" type="number" placeholder="300" id="timeout"helper="Maximum execution time in seconds (60-36000)." label="Timeout (seconds)" required />@if ($type === 'application')- <x-forms.input placeholder="php"+ <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="php"helper="You can leave this empty if your resource only has one container." id="container"label="Container name" />@elseif ($type === 'service')@@@ -54,6 -40,7 +43,7 @@@id="container" label="Service name" />@endif</div>- <x-forms.input placeholder="php artisan schedule:run" id="command" label="Command" required />++ <x-forms.input :disabled="!auth()->user()->can('update', $resource)" placeholder="php artisan schedule:run" id="command" label="Command" required /></form><div class="pt-4">diff --cc routes/web.phpindex b6c6c95ce0,fad3c5d297..df1d918d11--- a/routes/web.php+++ b/routes/web.php@@@ -33,7 -33,7 +33,6 @@@ use App\Livewire\Project\Service\Databause App\Livewire\Project\Service\Index as ServiceIndex;use App\Livewire\Project\Shared\ExecuteContainerCommand;use App\Livewire\Project\Shared\Logs;--use App\Livewire\Project\Shared\ScheduledTask\Show as ScheduledTaskShow;use App\Livewire\Project\Show as ProjectShow;use App\Livewire\Security\ApiTokens;use App\Livewire\Security\CloudInitScripts;diff --cc tests/Feature/CrossTeamIdorServerProjectTest.phpindex 0000000000,671397a1ed..95328c63f5mode 000000,100644..100644--- a/tests/Feature/CrossTeamIdorServerProjectTest.php+++ b/tests/Feature/CrossTeamIdorServerProjectTest.php@@@ -1,0 -1,182 +1,182 @@@+ <?php++ use App\Livewire\Boarding\Index as BoardingIndex;+ use App\Livewire\GlobalSearch;+ use App\Livewire\Project\CloneMe;+ use App\Livewire\Project\DeleteProject;+ use App\Models\Environment;+ use App\Models\Project;+ use App\Models\Server;+ use App\Models\StandaloneDocker;+ use App\Models\Team;+ use App\Models\User;+ use Illuminate\Foundation\Testing\RefreshDatabase;+ use Livewire\Livewire;++ uses(RefreshDatabase::class);++ beforeEach(function () {+ // Attacker: Team A+ $this->userA = User::factory()->create();+ $this->teamA = Team::factory()->create();+ $this->userA->teams()->attach($this->teamA, ['role' => 'owner']);++ $this->serverA = Server::factory()->create(['team_id' => $this->teamA->id]);+ $this->projectA = Project::factory()->create(['team_id' => $this->teamA->id]);+ $this->environmentA = Environment::factory()->create(['project_id' => $this->projectA->id]);++ // Victim: Team B+ $this->userB = User::factory()->create();+ $this->teamB = Team::factory()->create();+ $this->userB->teams()->attach($this->teamB, ['role' => 'owner']);++ $this->serverB = Server::factory()->create(['team_id' => $this->teamB->id]);+ $this->projectB = Project::factory()->create(['team_id' => $this->teamB->id]);+ $this->environmentB = Environment::factory()->create(['project_id' => $this->projectB->id]);++ // Act as attacker (Team A)+ $this->actingAs($this->userA);+ session(['currentTeam' => $this->teamA]);+ });++ describe('Boarding Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('boarding mount cannot load server from another team via selectedExistingServer', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedServerType' => 'remote',+ 'selectedExistingServer' => $this->serverB->id,+ ]);++ // The server from Team B should NOT be loaded+ expect($component->get('createdServer'))->toBeNull();+ });++ test('boarding mount can load own team server via selectedExistingServer', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedServerType' => 'remote',+ 'selectedExistingServer' => $this->serverA->id,+ ]);++ // Own team server should load successfully+ expect($component->get('createdServer'))->not->toBeNull();+ expect($component->get('createdServer')->id)->toBe($this->serverA->id);+ });+ });++ describe('Boarding Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('boarding mount cannot load project from another team via selectedProject', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedProject' => $this->projectB->id,+ ]);++ // The project from Team B should NOT be loaded+ expect($component->get('createdProject'))->toBeNull();+ });++ test('boarding selectExistingProject cannot load project from another team', function () {+ $component = Livewire::test(BoardingIndex::class)+ ->set('selectedProject', $this->projectB->id)+ ->call('selectExistingProject');++ expect($component->get('createdProject'))->toBeNull();+ $component->assertDispatched('error');+ });++ test('boarding selectExistingProject can load own team project', function () {+ $component = Livewire::test(BoardingIndex::class)+ ->set('selectedProject', $this->projectA->id)+ ->call('selectExistingProject');++ expect($component->get('createdProject'))->not->toBeNull();+ expect($component->get('createdProject')->id)->toBe($this->projectA->id);+ });+ });++ describe('GlobalSearch Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('loadDestinations cannot access server from another team', function () {+ $component = Livewire::test(GlobalSearch::class)+ ->set('selectedServerId', $this->serverB->id)+ ->call('loadDestinations');++ // Should dispatch error because server is not found (team-scoped)+ $component->assertDispatched('error');+ });+ });++ describe('GlobalSearch Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('loadEnvironments cannot access project from another team', function () {+ $component = Livewire::test(GlobalSearch::class)+ ->set('selectedProjectUuid', $this->projectB->uuid)+ ->call('loadEnvironments');++ // Should not load environments from another team's project+ expect($component->get('availableEnvironments'))->toBeEmpty();+ });+ });++ describe('DeleteProject IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('cannot mount DeleteProject with project from another team', function () {+ // Should throw ModelNotFoundException (404) because team-scoped query won't find it+ Livewire::test(DeleteProject::class, ['project_id' => $this->projectB->id]);+ })->throws(\Illuminate\Database\Eloquent\ModelNotFoundException::class);++ test('can mount DeleteProject with own team project', function () {+ $component = Livewire::test(DeleteProject::class, ['project_id' => $this->projectA->id]);++ expect($component->get('projectName'))->toBe($this->projectA->name);+ });+ });++ describe('CloneMe Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('cannot mount CloneMe with project UUID from another team', function () {+ // Should throw ModelNotFoundException because team-scoped query won't find it+ Livewire::test(CloneMe::class, [+ 'project_uuid' => $this->projectB->uuid,+ 'environment_uuid' => $this->environmentB->uuid,+ ]);+ })->throws(\Illuminate\Database\Eloquent\ModelNotFoundException::class);++ test('can mount CloneMe with own team project UUID', function () {+ $component = Livewire::test(CloneMe::class, [+ 'project_uuid' => $this->projectA->uuid,+ 'environment_uuid' => $this->environmentA->uuid,+ ]);++ expect($component->get('project_id'))->toBe($this->projectA->id);+ });+ });++ describe('DeployController API Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('deploy cancel API cannot access build server from another team', function () {+ // Create a deployment queue entry that references Team B's server as build_server+ $application = \App\Models\Application::factory()->create([+ 'environment_id' => $this->environmentA->id,+ 'destination_id' => StandaloneDocker::factory()->create(['server_id' => $this->serverA->id])->id,+ 'destination_type' => StandaloneDocker::class,+ ]);++ $deployment = \App\Models\ApplicationDeploymentQueue::create([+ 'application_id' => $application->id,- 'deployment_uuid' => 'test-deploy-' . fake()->uuid(),++ 'deployment_uuid' => 'test-deploy-'.fake()->uuid(),+ 'server_id' => $this->serverA->id,+ 'build_server_id' => $this->serverB->id, // Cross-team build server+ 'status' => \App\Enums\ApplicationDeploymentStatus::IN_PROGRESS->value,+ ]);++ $token = $this->userA->createToken('test-token', ['*']);++ $response = $this->withHeaders([- 'Authorization' => 'Bearer ' . $token->plainTextToken,++ 'Authorization' => 'Bearer '.$token->plainTextToken,+ ])->deleteJson("/api/v1/deployments/{$deployment->deployment_uuid}");++ // The cancellation should proceed but the build_server should NOT be found+ // (team-scoped query returns null for Team B's server)+ // The deployment gets cancelled but no remote process runs on the wrong server+ $response->assertOk();++ // Verify the deployment was cancelled+ $deployment->refresh();+ expect($deployment->status)->toBe(+ \App\Enums\ApplicationDeploymentStatus::CANCELLED_BY_USER->value+ );+ });+ });diff --cc tests/Feature/PushServerUpdateJobLastOnlineTest.phpindex 0000000000,5d2fd6c6ac..60d55f7402mode 000000,100644..100644--- a/tests/Feature/PushServerUpdateJobLastOnlineTest.php+++ b/tests/Feature/PushServerUpdateJobLastOnlineTest.php@@@ -1,0 -1,101 +1,100 @@@+ <?php++ use App\Jobs\PushServerUpdateJob;-use App\Models\Server;+ use App\Models\StandalonePostgresql;+ use App\Models\Team;+ use Illuminate\Foundation\Testing\RefreshDatabase;++ uses(RefreshDatabase::class);++ test('database last_online_at is updated when status unchanged', function () {+ $team = Team::factory()->create();+ $database = StandalonePostgresql::factory()->create([+ 'team_id' => $team->id,+ 'status' => 'running:healthy',+ 'last_online_at' => now()->subMinutes(5),+ ]);++ $server = $database->destination->server;++ $data = [+ 'containers' => [+ [+ 'name' => $database->uuid,+ 'state' => 'running',+ 'health_status' => 'healthy',+ 'labels' => [+ 'coolify.managed' => 'true',+ 'coolify.type' => 'database',+ 'com.docker.compose.service' => $database->uuid,+ ],+ ],+ ],+ ];++ $oldLastOnline = $database->last_online_at;++ $job = new PushServerUpdateJob($server, $data);+ $job->handle();++ $database->refresh();++ // last_online_at should be updated even though status didn't change+ expect($database->last_online_at->greaterThan($oldLastOnline))->toBeTrue();+ expect($database->status)->toBe('running:healthy');+ });++ test('database status is updated when container status changes', function () {+ $team = Team::factory()->create();+ $database = StandalonePostgresql::factory()->create([+ 'team_id' => $team->id,+ 'status' => 'exited',+ ]);++ $server = $database->destination->server;++ $data = [+ 'containers' => [+ [+ 'name' => $database->uuid,+ 'state' => 'running',+ 'health_status' => 'healthy',+ 'labels' => [+ 'coolify.managed' => 'true',+ 'coolify.type' => 'database',+ 'com.docker.compose.service' => $database->uuid,+ ],+ ],+ ],+ ];++ $job = new PushServerUpdateJob($server, $data);+ $job->handle();++ $database->refresh();++ expect($database->status)->toBe('running:healthy');+ });++ test('database is not marked exited when containers list is empty', function () {+ $team = Team::factory()->create();+ $database = StandalonePostgresql::factory()->create([+ 'team_id' => $team->id,+ 'status' => 'running:healthy',+ ]);++ $server = $database->destination->server;++ // Empty containers = Sentinel might have failed, should NOT mark as exited+ $data = [+ 'containers' => [],+ ];++ $job = new PushServerUpdateJob($server, $data);+ $job->handle();++ $database->refresh();++ // Status should remain running, NOT be set to exited+ expect($database->status)->toBe('running:healthy');+ });diff --cc tests/Unit/ProxyConfigRecoveryTest.phpindex 0000000000,e10d899fee..682407bdfemode 000000,100644..100644--- a/tests/Unit/ProxyConfigRecoveryTest.php+++ b/tests/Unit/ProxyConfigRecoveryTest.php@@@ -1,0 -1,173 +1,173 @@@+ <?php++ use App\Actions\Proxy\GetProxyConfiguration;+ use Illuminate\Support\Facades\Cache;+ use Illuminate\Support\Facades\Log;+ use Spatie\SchemalessAttributes\SchemalessAttributes;++ beforeEach(function () {+ Log::spy();+ Cache::spy();+ });++ function mockServerWithDbConfig(?string $savedConfig, string $proxyType = 'TRAEFIK'): object+ {+ $proxyAttributes = Mockery::mock(SchemalessAttributes::class);+ $proxyAttributes->shouldReceive('get')+ ->with('last_saved_proxy_configuration')+ ->andReturn($savedConfig);++ $proxyPath = match ($proxyType) {+ 'CADDY' => '/data/coolify/proxy/caddy',+ 'NGINX' => '/data/coolify/proxy/nginx',+ default => '/data/coolify/proxy/',+ };++ $server = Mockery::mock('App\Models\Server');+ $server->shouldIgnoreMissing();+ $server->shouldReceive('getAttribute')->with('proxy')->andReturn($proxyAttributes);+ $server->shouldReceive('getAttribute')->with('id')->andReturn(1);+ $server->shouldReceive('getAttribute')->with('name')->andReturn('Test Server');+ $server->shouldReceive('proxyType')->andReturn($proxyType);+ $server->shouldReceive('proxyPath')->andReturn($proxyPath);++ return $server;+ }++ it('returns OK for NONE proxy type without reading config', function () {+ $server = Mockery::mock('App\Models\Server');+ $server->shouldIgnoreMissing();+ $server->shouldReceive('proxyType')->andReturn('NONE');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe('OK');+ });++ it('reads proxy configuration from database', function () {+ $savedConfig = "services:\n traefik:\n image: traefik:v3.5\n";+ $server = mockServerWithDbConfig($savedConfig);++ // ProxyDashboardCacheService is called at the end — mock it+ $server->shouldReceive('proxyType')->andReturn('TRAEFIK');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($savedConfig);+ });++ it('preserves full custom config including labels, env vars, and custom commands', function () {+ $customConfig = <<<'YAML'+ services:+ traefik:+ image: traefik:v3.5+ command:+ - '--entrypoints.http.address=:80'+ - '--metrics.prometheus=true'+ labels:+ - 'traefik.enable=true'+ - 'waf.custom.middleware=true'+ environment:+ CF_API_EMAIL: [email protected]+ CF_API_KEY: secret-key+ YAML;++ $server = mockServerWithDbConfig($customConfig);++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($customConfig)+ ->and($result)->toContain('waf.custom.middleware=true')+ ->and($result)->toContain('CF_API_EMAIL')+ ->and($result)->toContain('metrics.prometheus=true');+ });++ it('logs warning when regenerating defaults', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ // No DB config, no disk config — will try to regenerate+ $server = mockServerWithDbConfig(null);++ // backfillFromDisk will be called — we need instant_remote_process to return empty+ // Since it's a global function we can't easily mock it, so test the logging via+ // the force regenerate path instead+ try {+ GetProxyConfiguration::run($server, forceRegenerate: true);+ } catch (\Throwable $e) {+ // generateDefaultProxyConfiguration may fail without full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'regenerated to defaults'))+ ->once();+ });++ it('does not read from disk when DB config exists', function () {+ $savedConfig = "services:\n traefik:\n image: traefik:v3.5\n";+ $server = mockServerWithDbConfig($savedConfig);++ // If disk were read, instant_remote_process would be called.+ // Since we're not mocking it and the test passes, it proves DB is used.+ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($savedConfig);+ });++ it('rejects stored Traefik config when proxy type is CADDY', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ $traefikConfig = "services:\n traefik:\n image: traefik:v3.6\n";+ $server = mockServerWithDbConfig($traefikConfig, 'CADDY');++ // Config type mismatch should trigger regeneration, which will try+ // backfillFromDisk (instant_remote_process) then generateDefault.+ // Both will fail in test env, but the warning log proves mismatch was detected.+ try {+ GetProxyConfiguration::run($server);+ } catch (\Throwable $e) {+ // Expected — regeneration requires SSH/full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'does not match current proxy type'))+ ->once();+ });++ it('rejects stored Caddy config when proxy type is TRAEFIK', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ $caddyConfig = "services:\n caddy:\n image: lucaslorentz/caddy-docker-proxy:2.8-alpine\n";+ $server = mockServerWithDbConfig($caddyConfig, 'TRAEFIK');++ try {+ GetProxyConfiguration::run($server);+ } catch (\Throwable $e) {+ // Expected — regeneration requires SSH/full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'does not match current proxy type'))+ ->once();+ });++ it('accepts stored Caddy config when proxy type is CADDY', function () {+ $caddyConfig = "services:\n caddy:\n image: lucaslorentz/caddy-docker-proxy:2.8-alpine\n";+ $server = mockServerWithDbConfig($caddyConfig, 'CADDY');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($caddyConfig);+ });++ it('accepts stored config when YAML parsing fails', function () {- $invalidYaml = "this: is: not: [valid yaml: {{{}}}";++ $invalidYaml = 'this: is: not: [valid yaml: {{{}}}';+ $server = mockServerWithDbConfig($invalidYaml, 'TRAEFIK');++ // Invalid YAML should not block — configMatchesProxyType returns true on parse failure+ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($invalidYaml);+ });