Skip to content

Commit def2fbe

Browse files
authored
Allow localhost for openhandler (#1598)
1 parent e564077 commit def2fbe

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

config/debugbar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
| Warning: Enabling storage.open will allow everyone to access previous
3535
| request, do not enable open storage in publicly available environments!
3636
| Specify a callback if you want to limit based on IP or authentication.
37+
| Leaving it to null will allow localhost only.
3738
*/
3839
'storage' => [
3940
'enabled' => true,
40-
'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback.
41+
'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback.
4142
'driver' => 'file', // redis, file, pdo, socket, custom
4243
'path' => storage_path('debugbar'), // For file driver
4344
'connection' => null, // Leave null for default connection (Redis/PDO)

src/Controllers/OpenHandlerController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ protected function isStorageOpen(Request $request)
2828
return method_exists($open, 'resolve') ? $open::resolve($request) : false;
2929
}
3030

31-
return is_bool($open) ? $open : false;
31+
if (is_bool($open)) {
32+
return $open;
33+
}
34+
35+
// Allow localhost request when not explicitly allowed/disallowed
36+
if (in_array($request->ip(), ['127.0.0.1', '::1'], true)) {
37+
return true;
38+
}
39+
40+
return false;
3241
}
3342

3443
public function handle(Request $request)

0 commit comments

Comments
 (0)