mirror of
https://github.com/grokability/snipe-it.git
synced 2026-03-12 17:52:00 +08:00
Move Passport 13 key permission normalization to upgrade.php to cover existing installs with incorrect permissions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user