From 9db038e4bbb255de52dba95e7f3ba271631ed5b3 Mon Sep 17 00:00:00 2001 From: Anil Kulkarni Date: Sun, 18 Aug 2024 11:50:04 -0700 Subject: [PATCH] Check for oauth keys from the config, as well as from disk --- app/Http/Controllers/Admin/AdminDirectoryController.php | 4 +++- app/Http/Controllers/Admin/AdminSettingsController.php | 4 +++- app/Http/Controllers/PixelfedDirectoryController.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminDirectoryController.php b/app/Http/Controllers/Admin/AdminDirectoryController.php index ce53ea560..a5923894b 100644 --- a/app/Http/Controllers/Admin/AdminDirectoryController.php +++ b/app/Http/Controllers/Admin/AdminDirectoryController.php @@ -67,7 +67,9 @@ trait AdminDirectoryController $res['community_guidelines'] = config_cache('app.rules') ? json_decode(config_cache('app.rules'), true) : []; $res['curated_onboarding'] = (bool) config_cache('instance.curated_registration.enabled'); $res['open_registration'] = (bool) config_cache('pixelfed.open_registration'); - $res['oauth_enabled'] = (bool) config_cache('pixelfed.oauth_enabled') && file_exists(storage_path('oauth-public.key')) && file_exists(storage_path('oauth-private.key')); + $res['oauth_enabled'] = (bool) config_cache('pixelfed.oauth_enabled') && + (file_exists(storage_path('oauth-public.key')) || config_cache('passport.public_key')) && + (file_exists(storage_path('oauth-private.key')) || config_cache('passport.private_key')); $res['activitypub_enabled'] = (bool) config_cache('federation.activitypub.enabled'); diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index f1c2ca3ab..17ffd98fc 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -195,7 +195,9 @@ trait AdminSettingsController if ($key == 'mobile_apis' && $active && ! file_exists(storage_path('oauth-public.key')) && - ! file_exists(storage_path('oauth-private.key')) + ! config_cache('passport.public_key') && + ! file_exists(storage_path('oauth-private.key')) && + ! config_cache('passport.private_key') ) { Artisan::call('passport:keys'); Artisan::call('route:cache'); diff --git a/app/Http/Controllers/PixelfedDirectoryController.php b/app/Http/Controllers/PixelfedDirectoryController.php index 0477c5170..d6a014d07 100644 --- a/app/Http/Controllers/PixelfedDirectoryController.php +++ b/app/Http/Controllers/PixelfedDirectoryController.php @@ -90,7 +90,8 @@ class PixelfedDirectoryController extends Controller $oauthEnabled = ConfigCache::whereK('pixelfed.oauth_enabled')->first(); if ($oauthEnabled) { - $keys = file_exists(storage_path('oauth-public.key')) && file_exists(storage_path('oauth-private.key')); + $keys = (file_exists(storage_path('oauth-public.key')) || config_cache('passport.public_key')) && + (file_exists(storage_path('oauth-private.key')) || config_cache('passport.private_key')); $res['oauth_enabled'] = (bool) $oauthEnabled && $keys; }