From 1dd69c906cdefd0271e5644488d0b253f5372f32 Mon Sep 17 00:00:00 2001 From: Kyle Ferguson Date: Mon, 30 Jan 2017 10:38:46 -0500 Subject: [PATCH] basic auth for ui --- src/Support/HealthzServiceProvider.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Support/HealthzServiceProvider.php b/src/Support/HealthzServiceProvider.php index 47ee92b..745ea40 100644 --- a/src/Support/HealthzServiceProvider.php +++ b/src/Support/HealthzServiceProvider.php @@ -47,6 +47,17 @@ protected function healthzHandler() protected function healthzUIHandler() { return function() { + $username = getenv('HEALTHZ_USERNAME'); + $password = getenv('HEALTHZ_PASSWORD'); + if ($username != "") { + if ( + request()->getUser() !== $username || + request()->getPassword() !== $password + ) { + return response('Invalid credentials', 401, ['WWW-Authenticate' => 'Basic']); + } + } + $healthz = app(Healthz::class); $results = $healthz->run(); $html = $healthz->html($results);