From ed12f7348371c3585e1bab3f08c6d2962f113b9b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 13:33:34 +0100 Subject: [PATCH 01/28] Update admin authentication and version numbers --- app/Livewire/Admin/Index.php | 2 +- config/sentry.php | 2 +- config/version.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 3c13cd771..b6116d337 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,7 @@ class Index extends Component public $users = []; public function mount() { - if (auth()->user()->id !== 0 && session('adminToken') === null) { + if (instanceAdmin() && session('adminToken') === null) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { diff --git a/config/sentry.php b/config/sentry.php index 5f2ea6fb6..4a2eff3f2 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.212', + 'release' => '4.0.0-beta.213', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 01e2a62f9..b1372fd9d 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 8 Feb 2024 13:33:51 +0100 Subject: [PATCH 02/28] Fix isInstanceAdmin function call in Index.php --- app/Livewire/Admin/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index b6116d337..4fe430538 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,7 @@ class Index extends Component public $users = []; public function mount() { - if (instanceAdmin() && session('adminToken') === null) { + if (isInstanceAdmin() && session('adminToken') === null) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { From d7001937ac722ee3ea899c8ea7374abe05e8b057 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 13:40:26 +0100 Subject: [PATCH 03/28] Fix access control in Admin Index and Navbar components --- app/Livewire/Admin/Index.php | 2 +- resources/views/components/navbar.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 4fe430538..888a29233 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,7 @@ class Index extends Component public $users = []; public function mount() { - if (isInstanceAdmin() && session('adminToken') === null) { + if (!isInstanceAdmin() && session('adminToken') === null) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index e4cafb6b9..04ce6257f 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -142,7 +142,7 @@ - @if (isCloud()) + @if (isCloud() && isInstanceAdmin())
  • From 59c3cc6ce1ce9cfa2827f557684fc822934e690b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 13:46:43 +0100 Subject: [PATCH 04/28] Refactor admin authentication logic in Index component --- app/Livewire/Admin/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 888a29233..1908fe107 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,7 @@ class Index extends Component public $users = []; public function mount() { - if (!isInstanceAdmin() && session('adminToken') === null) { + if (!isInstanceAdmin()) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { From 9350fb4b9713def74947d392e966542aaf2af92b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 13:54:16 +0100 Subject: [PATCH 05/28] Fix access control in Admin Index and hide Admin link in navbar --- app/Livewire/Admin/Index.php | 2 +- resources/views/components/navbar.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 1908fe107..75b3f1d22 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,7 @@ class Index extends Component public $users = []; public function mount() { - if (!isInstanceAdmin()) { + if (auth()->user()->id !== 0) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 04ce6257f..5d7eae25b 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -142,7 +142,7 @@ - @if (isCloud() && isInstanceAdmin()) + {{-- @if (isCloud() && isInstanceAdmin())
  • @@ -151,7 +151,7 @@
  • - @endif + @endif --}}
    @if (isInstanceAdmin() && !isCloud()) @persist('upgrade') From 7e7f322e21f89d770d5db1a9402d4655fe4cea79 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 14:01:16 +0100 Subject: [PATCH 06/28] Refactor admin authentication and routing*** ***Add redirect for non-cloud users and instance admins without admin token.*** ***Always include admin route, regardless of cloud status. --- app/Livewire/Admin/Index.php | 5 ++++- routes/web.php | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 75b3f1d22..95a7dd2ae 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -11,7 +11,10 @@ class Index extends Component public $users = []; public function mount() { - if (auth()->user()->id !== 0) { + if (!isCloud()) { + return redirect()->route('dashboard'); + } + if (!isInstanceAdmin() && session('adminToken') === null) { return redirect()->route('dashboard'); } $this->users = User::whereHas('teams', function ($query) { diff --git a/routes/web.php b/routes/web.php index bb3ca6e34..12e3c4a8d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -79,9 +79,7 @@ use App\Livewire\Waitlist\Index as WaitlistIndex; if (isDev()) { Route::get('/dev/compose', Compose::class)->name('dev.compose'); } -if (isCloud()) { - Route::get('/admin', AdminIndex::class)->name('admin.index'); -} +Route::get('/admin', AdminIndex::class)->name('admin.index'); Route::post('/forgot-password', [Controller::class, 'forgot_password'])->name('password.forgot'); Route::get('/api/v1/test/realtime', [Controller::class, 'realtime_test'])->middleware('auth'); From 7c395edab476f9f0029b5ffcf4396ed235809d44 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 14:06:43 +0100 Subject: [PATCH 07/28] Fix conditional statement in navbar.blade.php --- resources/views/components/navbar.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 5d7eae25b..04ce6257f 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -142,7 +142,7 @@ - {{-- @if (isCloud() && isInstanceAdmin()) + @if (isCloud() && isInstanceAdmin())
  • @@ -151,7 +151,7 @@
  • - @endif --}} + @endif
    @if (isInstanceAdmin() && !isCloud()) @persist('upgrade') From 3d2444ab2ec5668f0252aa292afbad33b1777a1d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 14:54:30 +0100 Subject: [PATCH 08/28] Update version 4 to 4.0.0-beta.213 --- versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.json b/versions.json index f00b32a21..0de695692 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.212" + "version": "4.0.0-beta.213" } } } From 8a50b063d47ea87d73d55b4dcb9103b006b3546a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 15:22:07 +0100 Subject: [PATCH 09/28] fix: user proper image_tag, if set --- app/Jobs/ApplicationDeploymentJob.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 1b14e7e12..ccf1bba3d 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -618,6 +618,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } } else { $this->dockerImageTag = str($this->commit)->substr(0, 128); + if ($this->application->docker_registry_image_tag) { + $this->dockerImageTag = $this->application->docker_registry_image_tag; + } if ($this->application->docker_registry_image_name) { $this->build_image_name = Str::lower("{$this->application->docker_registry_image_name}:{$this->dockerImageTag}-build"); $this->production_image_name = Str::lower("{$this->application->docker_registry_image_name}:{$this->dockerImageTag}"); From 29676ffb22570a2bb2ae2b55a0e4fc1727f36b98 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 9 Feb 2024 08:42:39 +0100 Subject: [PATCH 10/28] Update Teams link in navbar.blade.php --- resources/views/components/navbar.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 04ce6257f..24100b9ec 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -120,7 +120,7 @@ - Teams + Teams @if(isCloud())/ Subscription @endif @if (isInstanceAdmin()) From 798d7471647a5b242af347fcaa30b4a893fbe508 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 9 Feb 2024 13:38:17 +0100 Subject: [PATCH 11/28] add Docker run command parse test --- bootstrap/helpers/docker.php | 17 +++-------------- tests/Feature/DockerRunTest.php | 9 +++++++++ tests/Feature/ExampleTest.php | 7 ------- tests/Feature/ParseServiceTest.php | 7 ------- tests/Pest.php | 2 +- tests/Unit/ExampleTest.php | 5 ----- tests/Unit/RulesTest.php | 5 ----- 7 files changed, 13 insertions(+), 39 deletions(-) create mode 100644 tests/Feature/DockerRunTest.php delete mode 100644 tests/Feature/ExampleTest.php delete mode 100644 tests/Feature/ParseServiceTest.php delete mode 100644 tests/Unit/ExampleTest.php delete mode 100644 tests/Unit/RulesTest.php diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 3ebec43b9..eb0898bfd 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -349,18 +349,8 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null foreach ($matches as $match) { $option = $match[1]; $value = isset($match[2]) && $match[2] !== '' ? $match[2] : true; - if ($list_options->contains($option)) { - $value = explode(',', $value); - } - if (array_key_exists($option, $options)) { - if (is_array($options[$option])) { - $options[$option][] = $value; - } else { - $options[$option] = [$options[$option], $value]; - } - } else { - $options[$option] = $value; - } + $options[$option][] = $value; + $options[$option] = array_unique($options[$option]); } $options = collect($options); // Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js @@ -370,7 +360,7 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null } if ($option === '--ulimit') { $ulimits = collect([]); - collect($value)->map(function ($ulimit) use ($ulimits){ + collect($value)->map(function ($ulimit) use ($ulimits) { $ulimit = explode('=', $ulimit); $type = $ulimit[0]; $limits = explode(':', $ulimit[1]); @@ -381,7 +371,6 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null 'soft' => $soft_limit, 'hard' => $hard_limit ]); - } else { $soft_limit = $ulimit[1]; $ulimits->put($type, [ diff --git a/tests/Feature/DockerRunTest.php b/tests/Feature/DockerRunTest.php new file mode 100644 index 000000000..8821d1ad4 --- /dev/null +++ b/tests/Feature/DockerRunTest.php @@ -0,0 +1,9 @@ +toBe([ + 'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'], + ])->ray(); +}); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index e07cdfb06..000000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/api/health'); - - $response->assertStatus(200); -}); diff --git a/tests/Feature/ParseServiceTest.php b/tests/Feature/ParseServiceTest.php deleted file mode 100644 index a48119799..000000000 --- a/tests/Feature/ParseServiceTest.php +++ /dev/null @@ -1,7 +0,0 @@ -toBe(3); - }); diff --git a/tests/Pest.php b/tests/Pest.php index 50ab1e433..fa6dc801f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -12,7 +12,7 @@ */ uses( - Tests\TestCase::class, + // Tests\TestCase::class, // Illuminate\Foundation\Testing\RefreshDatabase::class, )->in('Feature'); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 44a4f337a..000000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); diff --git a/tests/Unit/RulesTest.php b/tests/Unit/RulesTest.php deleted file mode 100644 index 585e7126c..000000000 --- a/tests/Unit/RulesTest.php +++ /dev/null @@ -1,5 +0,0 @@ -expect(['dd', 'dump']) - ->not->toBeUsed(); From 047922b13af75d1489cdb46bc7e8145f208ba17a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 9 Feb 2024 13:48:40 +0100 Subject: [PATCH 12/28] fix: new menu ui --- resources/views/components/navbar.blade.php | 209 +++++++++++--------- 1 file changed, 115 insertions(+), 94 deletions(-) diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 24100b9ec..ade76c16e 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -40,105 +40,125 @@ - -