From 587a927b8b683f7d505be86d897f5a94d5809400 Mon Sep 17 00:00:00 2001 From: Arnaud Dezandee <4415204+arnaud-dezandee@users.noreply.github.com> Date: Tue, 20 May 2025 14:35:39 +0200 Subject: [PATCH] feat(oauth): set redirect uri as optional and add default value (#5760) --- app/Models/OauthSetting.php | 6 +++--- bootstrap/helpers/socialite.php | 4 ++++ resources/views/livewire/settings-oauth.blade.php | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/OauthSetting.php b/app/Models/OauthSetting.php index 3d82e89f2..bfd332c87 100644 --- a/app/Models/OauthSetting.php +++ b/app/Models/OauthSetting.php @@ -25,11 +25,11 @@ class OauthSetting extends Model { switch ($this->provider) { case 'azure': - return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->tenant); + return filled($this->client_id) && filled($this->client_secret) && filled($this->tenant); case 'authentik': - return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->base_url); + return filled($this->client_id) && filled($this->client_secret) && filled($this->base_url); default: - return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri); + return filled($this->client_id) && filled($this->client_secret); } } } diff --git a/bootstrap/helpers/socialite.php b/bootstrap/helpers/socialite.php index 16870e33d..fe19752cb 100644 --- a/bootstrap/helpers/socialite.php +++ b/bootstrap/helpers/socialite.php @@ -7,6 +7,10 @@ function get_socialite_provider(string $provider) { $oauth_setting = OauthSetting::firstWhere('provider', $provider); + if (! filled($oauth_setting->redirect_uri)) { + $oauth_setting->update(['redirect_uri' => route('auth.callback', $provider)]); + } + if ($provider === 'azure') { $azure_config = new \SocialiteProviders\Manager\Config( $oauth_setting->client_id, diff --git a/resources/views/livewire/settings-oauth.blade.php b/resources/views/livewire/settings-oauth.blade.php index 7062ef4d4..76d03dc14 100644 --- a/resources/views/livewire/settings-oauth.blade.php +++ b/resources/views/livewire/settings-oauth.blade.php @@ -26,7 +26,7 @@ label="Client ID" /> - @if ($oauth_setting->provider == 'azure')