A free open source IT asset/license management system
normalize key permissions
Joël Pittet5800d0820220
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.phpindex a2ccb62475..e819ade900 100755--- a/app/Http/Controllers/DashboardController.php+++ b/app/Http/Controllers/DashboardController.php@@ -41,6 +41,7 @@ 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);@@ -51,4 +52,24 @@ 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 a81da7b9ff..19eb9e46d9 100644--- a/app/Http/Controllers/SetupController.php+++ b/app/Http/Controllers/SetupController.php@@ -251,6 +251,7 @@ 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')@@ -261,6 +262,27 @@ 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);+ }+ }+