Skip to content

Commit

Permalink
Allow localhost for openhandler (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Apr 1, 2024
1 parent e564077 commit def2fbe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/debugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
| 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)
Expand Down
11 changes: 10 additions & 1 deletion src/Controllers/OpenHandlerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ protected function isStorageOpen(Request $request)
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)
Expand Down

0 comments on commit def2fbe

Please sign in to comment.