Move Passport 13 key permission normalization to upgrade.php to cover existing installs with incorrect permissions

This commit is contained in:
Joël Pittet
2026-03-07 22:22:46 -08:00
parent 5800d08202
commit a956676745
3 changed files with 7 additions and 45 deletions

View File

@@ -41,7 +41,6 @@ class DashboardController extends Controller
if ((! 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 Controller
return 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);
}
}
}

View File

@@ -251,7 +251,6 @@ class SetupController extends Controller
if ((! 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);
}
}

View File

@@ -612,6 +612,13 @@ if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-p
echo $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";