A free open source IT asset/license management system
Move Passport 13 key permission normalization to upgrade.php to cover existing installs with incorrect permissions
Joël Pitteta95667674550
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.phpindex e819ade900..a2ccb62475 100755--- a/app/Http/Controllers/DashboardController.php+++ b/app/Http/Controllers/DashboardController.php@@ -41,7 +41,6 @@ class DashboardController extends Controllerif ((! file_exists(storage_path().'/oauth-private.key')) || (! file_exists(storage_path().'/oauth-public.key'))) {Artisan::call('migrate', ['--force' => true]);Artisan::call('passport:install', ['--no-interaction' => true]);- $this->normalizePassportKeyPermissions();}return view('dashboard')->with('asset_stats', $asset_stats)->with('counts', $counts);@@ -52,24 +51,4 @@ class DashboardController extends Controllerreturn redirect()->intended('account/view-assets');}}- /**- * Normalize Passport key permissions to satisfy Passport 13 validation.- */- protected function normalizePassportKeyPermissions(): void- {- if (windows_os()) {- return;- }-- $privateKey = storage_path('oauth-private.key');- $publicKey = storage_path('oauth-public.key');-- if (is_file($privateKey) && is_writable($privateKey)) {- chmod($privateKey, 0600);- }-- if (is_file($publicKey) && is_writable($publicKey)) {- chmod($publicKey, 0660);- }- }}diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.phpindex 19eb9e46d9..edf45bb98b 100644--- a/app/Http/Controllers/SetupController.php+++ b/app/Http/Controllers/SetupController.php@@ -251,7 +251,6 @@ class SetupController extends Controllerif ((! file_exists(storage_path().'/oauth-private.key')) || (! file_exists(storage_path().'/oauth-public.key'))) {Artisan::call('migrate', ['--path' => 'vendor/laravel/passport/database/migrations', '--force' => true]);Artisan::call('passport:install', ['--no-interaction' => true]);- $this->normalizePassportKeyPermissions();}return view('setup/migrate')@@ -262,29 +261,6 @@ class SetupController extends Controller->with('icon', 'fa-solid fa-database');}- /**- * Normalize Passport key permissions to satisfy Passport 13 validation.- */- protected function normalizePassportKeyPermissions(): void- {- if (windows_os()) {- return;- }-- $privateKey = storage_path('oauth-private.key');- $publicKey = storage_path('oauth-public.key');-- if (is_file($privateKey) && is_writable($privateKey)) {- chmod($privateKey, 0600);- }-- if (is_file($publicKey) && is_writable($publicKey)) {- chmod($publicKey, 0660);- }- }---diff --git a/upgrade.php b/upgrade.phpindex ae24661a47..d8daade4e1 100644--- a/upgrade.php+++ b/upgrade.php@@ -612,6 +612,13 @@ if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-pecho $success_icon." OAuth keys detected. Skipping passport install.\n\n";}+// Normalize key permissions for Passport 13 (covers both fresh installs and upgrades)+if (PHP_OS !== 'WINNT') {+ if (file_exists('storage/oauth-private.key')) chmod('storage/oauth-private.key', 0600);+ if (file_exists('storage/oauth-public.key')) chmod('storage/oauth-public.key', 0660);+ echo $success_icon." OAuth key permissions normalized.\n\n";+}+echo "\e[95m--------------------------------------------------------\n";echo "STEP 11: Taking application out of maintenance mode:\n";