diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 0cd685e59ee8..d7807ef6cc04 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -15,7 +15,8 @@ class DownCommand extends Command * @var string */ protected $signature = 'down {--message= : The message for the maintenance mode. } - {--retry= : The number of seconds after which the request may be retried.}'; + {--retry= : The number of seconds after which the request may be retried.} + {--allow=* : Ip or network allowed to use App in the maintenance mode.}'; /** * The console command description. @@ -50,6 +51,7 @@ protected function getDownFilePayload() 'time' => $this->currentTime(), 'message' => $this->option('message'), 'retry' => $this->getRetryTime(), + 'allowed' => $this->option('allow'), ]; } diff --git a/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php b/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php index 6de75096dbc7..7e6581c9143d 100644 --- a/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php +++ b/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Contracts\Foundation\Application; use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException; +use Symfony\Component\HttpFoundation\IpUtils; class CheckForMaintenanceMode { @@ -40,6 +41,10 @@ public function handle($request, Closure $next) if ($this->app->isDownForMaintenance()) { $data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true); + if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array)$data['allowed'])) { + return $next($request); + } + throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']); }