From b5be17c2d2844199ec4df9707b6c8f71826767cd Mon Sep 17 00:00:00 2001 From: Kenneth Thomsen Date: Wed, 19 Jun 2024 13:36:00 +0200 Subject: [PATCH 01/20] Fixed OAuth signin bug, ignoring the 'Allow Registration'-setting and registers a new user, even when the setting is disabled --- app/Http/Controllers/OauthController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/OauthController.php b/app/Http/Controllers/OauthController.php index 5b17fe926..9569e8cfa 100644 --- a/app/Http/Controllers/OauthController.php +++ b/app/Http/Controllers/OauthController.php @@ -2,8 +2,10 @@ namespace App\Http\Controllers; +use App\Models\InstanceSettings; use App\Models\User; use Illuminate\Support\Facades\Auth; +use Symfony\Component\HttpKernel\Exception\HttpException; class OauthController extends Controller { @@ -20,6 +22,11 @@ class OauthController extends Controller $oauthUser = get_socialite_provider($provider)->user(); $user = User::whereEmail($oauthUser->email)->first(); if (! $user) { + $settings = InstanceSettings::get(); + if (! $settings->is_registration_enabled) { + abort(403, 'Registration is disabled'); + } + $user = User::create([ 'name' => $oauthUser->name, 'email' => $oauthUser->email, @@ -31,7 +38,9 @@ class OauthController extends Controller } catch (\Exception $e) { ray($e->getMessage()); - return redirect()->route('login')->withErrors([__('auth.failed.callback')]); + $errorCode = $e instanceof HttpException ? 'auth.failed' : 'auth.failed.callback'; + + return redirect()->route('login')->withErrors([__($errorCode)]); } } } From 5232ce6e52c175c2bd6be779c508bb4935fb0fbd Mon Sep 17 00:00:00 2001 From: Ruslan Suleimanov Date: Wed, 19 Jun 2024 20:54:52 +0200 Subject: [PATCH 02/20] use the right key --- templates/compose/supabase.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/supabase.yaml b/templates/compose/supabase.yaml index 0d0ef2f1d..3004a90be 100644 --- a/templates/compose/supabase.yaml +++ b/templates/compose/supabase.yaml @@ -1012,7 +1012,7 @@ services: "-o", "/dev/null", "-H", - "Authorization: Bearer ${ANON_KEY}", + "Authorization: Bearer ${SERVICE_SUPABASEANON_KEY}", "http://127.0.0.1:4000/api/tenants/realtime-dev/health" ] timeout: 5s From bdcb46720854f0a074e10ab0948b3b0fc63e7bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Sz=C3=BCcs?= <2458236+martonsz@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:39:41 +0200 Subject: [PATCH 03/20] Fix healthcheck for Postgres in Authentic compose stack Postgres would never get in healthy state because the environment variable SERVICE_USER_POSTGRESQL was never set inside the container. Using POSTGRES_USER container env instead which receives the value from SERVICE_USER_POSTGRESQL. Also adding the condition "service_healthy" for the depends_on. This will make the Authentic containers to wait for Postgres and Redis to be healthy before starting. --- templates/compose/authentik.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/templates/compose/authentik.yaml b/templates/compose/authentik.yaml index 51360e349..4fa7a7617 100644 --- a/templates/compose/authentik.yaml +++ b/templates/compose/authentik.yaml @@ -9,7 +9,7 @@ services: image: docker.io/library/postgres:12-alpine restart: unless-stopped healthcheck: - test: ["CMD-SHELL", "pg_isready -d authentik -U $${SERVICE_USER_POSTGRESQL}"] + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] interval: 2s timeout: 10s retries: 15 @@ -55,8 +55,10 @@ services: - ./media:/media - ./custom-templates:/templates depends_on: - - postgresql - - redis + postgresql: + condition: service_healthy + redis: + condition: service_healthy authentik-worker: image: ghcr.io/goauthentik/server:${AUTHENTIK_TAG:-2024.2.2} restart: unless-stopped @@ -90,5 +92,7 @@ services: - ./certs:/certs - ./custom-templates:/templates depends_on: - - postgresql - - redis + postgresql: + condition: service_healthy + redis: + condition: service_healthy From c5083ea897932d2785491350dd77196c05422f2b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 21 Jun 2024 13:54:13 +0200 Subject: [PATCH 04/20] feat: preselect prod or first env when selecting a project feat: quickly switch between environments --- .../Project/Resource/EnvironmentSelect.php | 35 +++++++++++++++++++ app/Models/Project.php | 10 ++++++ .../views/livewire/project/index.blade.php | 2 +- .../resource/environment-select.blade.php | 8 +++++ .../livewire/project/resource/index.blade.php | 6 +++- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 app/Livewire/Project/Resource/EnvironmentSelect.php create mode 100644 resources/views/livewire/project/resource/environment-select.blade.php diff --git a/app/Livewire/Project/Resource/EnvironmentSelect.php b/app/Livewire/Project/Resource/EnvironmentSelect.php new file mode 100644 index 000000000..efb1b6ca2 --- /dev/null +++ b/app/Livewire/Project/Resource/EnvironmentSelect.php @@ -0,0 +1,35 @@ +selectedEnvironment = request()->route('environment_name'); + $this->project_uuid = request()->route('project_uuid'); + } + + public function updatedSelectedEnvironment($value) + { + if ($value === 'edit') { + return redirect()->route('project.show', [ + 'project_uuid' => $this->project_uuid, + ]); + } else { + return redirect()->route('project.resource.index', [ + 'project_uuid' => $this->project_uuid, + 'environment_name' => $value, + ]); + } + } +} diff --git a/app/Models/Project.php b/app/Models/Project.php index acc98e341..1cbce6cac 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -112,4 +112,14 @@ class Project extends BaseModel { return $this->postgresqls()->get()->merge($this->redis()->get())->merge($this->mongodbs()->get())->merge($this->mysqls()->get())->merge($this->mariadbs()->get())->merge($this->keydbs()->get())->merge($this->dragonflies()->get())->merge($this->clickhouses()->get()); } + + public function default_environment() + { + $default = $this->environments()->where('name', 'production')->first(); + if (! $default) { + $default = $this->environments()->sortBy('created_at')->first(); + } + + return $default; + } } diff --git a/resources/views/livewire/project/index.blade.php b/resources/views/livewire/project/index.blade.php index b720885ff..0a5cb26bb 100644 --- a/resources/views/livewire/project/index.blade.php +++ b/resources/views/livewire/project/index.blade.php @@ -13,7 +13,7 @@ @forelse ($projects as $project) @@ -43,8 +44,11 @@ +
+ +
@if ($environment->isEmpty()) - + Add New Resource @else
From f5cea7d9e36d14c685c79c6090327f6822842ad0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 21 Jun 2024 13:56:07 +0200 Subject: [PATCH 05/20] refactor: Update profile index view to display 2FA QR code in a centered container --- resources/views/livewire/profile/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/profile/index.blade.php b/resources/views/livewire/profile/index.blade.php index b2583519b..0648016b7 100644 --- a/resources/views/livewire/profile/index.blade.php +++ b/resources/views/livewire/profile/index.blade.php @@ -40,7 +40,7 @@ Validate 2FA
-
{!! request()->user()->twoFactorQrCodeSvg() !!}
+
{!! request()->user()->twoFactorQrCodeSvg() !!}