Allow localhost for openhandler (#1598)

This commit is contained in:
Barry vd. Heuvel 2024-04-01 17:06:45 +02:00 committed by GitHub
parent e564077757
commit def2fbeeba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -34,10 +34,11 @@ return [
| Warning: Enabling storage.open will allow everyone to access previous
| request, do not enable open storage in publicly available environments!
| Specify a callback if you want to limit based on IP or authentication.
| Leaving it to null will allow localhost only.
*/
'storage' => [
'enabled' => true,
'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback.
'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback.
'driver' => 'file', // redis, file, pdo, socket, custom
'path' => storage_path('debugbar'), // For file driver
'connection' => null, // Leave null for default connection (Redis/PDO)

View File

@ -28,7 +28,16 @@ class OpenHandlerController extends BaseController
return method_exists($open, 'resolve') ? $open::resolve($request) : false;
}
return is_bool($open) ? $open : false;
if (is_bool($open)) {
return $open;
}
// Allow localhost request when not explicitly allowed/disallowed
if (in_array($request->ip(), ['127.0.0.1', '::1'], true)) {
return true;
}
return false;
}
public function handle(Request $request)