Skip to content

Commit

Permalink
LETS MAKE HTTP AUTH GREAT AGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobemerick committed May 28, 2016
1 parent 6f138ac commit 1f179ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bootstrap.php
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions 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]

0 comments on commit 1f179ab

Please sign in to comment.