Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(oauth): set redirect uri as optional and add default value (#5760)

Arnaud Dezandee587a927b8b68
diff --git a/app/Models/OauthSetting.php b/app/Models/OauthSetting.php
index 3d82e89f29..bfd332c87c 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 16870e33d3..fe19752cba 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 7062ef4d45..76d03dc14a 100644
--- a/resources/views/livewire/settings-oauth.blade.php
+++ b/resources/views/livewire/settings-oauth.blade.php
@@ -26,7 +26,7 @@
label="Client ID" />
<x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.client_secret"
type="password" label="Client Secret" autocomplete="new-password" />
- <x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.redirect_uri"
+ <x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.redirect_uri" placeholder="{{ route('auth.callback', $oauth_setting->provider) }}"
label="Redirect URI" />
@if ($oauth_setting->provider == 'azure')
<x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.tenant"