From d1c2a05b872a606096a69bc7686be66bd5d252b4 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:14:31 +0200 Subject: [PATCH] Log error & Check OpenID config to ease SSO setup - See #325 --- app/Http/Controllers/Auth/SocialiteController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Http/Controllers/Auth/SocialiteController.php b/app/Http/Controllers/Auth/SocialiteController.php index 17d70b67c..e92f66609 100644 --- a/app/Http/Controllers/Auth/SocialiteController.php +++ b/app/Http/Controllers/Auth/SocialiteController.php @@ -8,6 +8,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Laravel\Socialite\Facades\Socialite; @@ -20,10 +21,16 @@ class SocialiteController extends Controller */ public function redirect(Request $request, string $driver) { + // Generic SSO provider definition check if (! config('services.' . $driver . '.client_id') || ! config('services.' . $driver . '.client_secret')) { return redirect('/error?err=sso_bad_provider_setup'); } + // OpenID SSO provider definition check + if ($driver == 'openid' && (! config('services.openid.token_url') || ! config('services.openid.authorize_url') || ! config('services.openid.userinfo_url'))) { + return redirect('/error?err=sso_bad_provider_setup'); + } + return Settings::get('enableSso') ? Socialite::driver($driver)->redirect() : redirect('/error?err=sso_disabled'); @@ -39,6 +46,8 @@ public function callback(Request $request, string $driver) try { $socialiteUser = Socialite::driver($driver)->user(); } catch (\Exception $e) { + Log::error($e); + return redirect('/error?err=sso_failed'); }