From 1f179ab1167ec28ca0fdae9c9b774a0ab243298d Mon Sep 17 00:00:00 2001 From: jacobemerick Date: Fri, 27 May 2016 20:52:20 -0700 Subject: [PATCH] LETS MAKE HTTP AUTH GREAT AGAIN --- bootstrap.php | 5 +++++ public/.htaccess | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index ada2a16..5a8c342 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -39,6 +39,11 @@ $talus->addMiddleware(function ($req, $res, $next) use ($auth) { $authHeader = base64_encode("{$auth->username}:{$auth->password}"); $authHeader = "Basic {$authHeader}"; + + if ($_SERVER['REDIRECT_X_HTTP_AUTHORIZATION']) { + $req = $req->withHeader('Authorization', $_SERVER['REDIRECT_X_HTTP_AUTHORIZATION']); + } + if ($authHeader != current($req->getHeader('Authorization'))) { $res = $res->withStatus(403); return $res; diff --git a/public/.htaccess b/public/.htaccess index 0697350..f842bae 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,6 +1,5 @@ -RewriteEngine On -RewriteRule ^$ index.php [QSA] -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ index.php/$1 [QSA,L] +RewriteEngine on +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]