Skip to content

Commit

Permalink
Fix #84 - Reverse proxy guard authenticates even with invalid headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed May 18, 2022
1 parent c2edd69 commit 0199ad3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Services/Auth/ReverseProxyGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function user()
$user = null;

// Get the user identifier from $_SERVER or apache filtered headers
$remoteUserHeader = config('auth.auth_proxy_headers.user', 'REMOTE_USER');
$remoteUserHeader = config('auth.auth_proxy_headers.user');
$remoteUserHeader = $remoteUserHeader ?: 'REMOTE_USER';

try {
$identifier['user'] = request()->server($remoteUserHeader) ?? apache_request_headers()[$remoteUserHeader] ?? null;
Expand All @@ -78,8 +79,8 @@ public function user()
$identifier['user'] = null;
}

if (! $identifier['user']) {
Log::error(sprintf('No user in header "%s".', $remoteUserHeader));
if (!$identifier['user'] || is_array($identifier['user'])) {
Log::error(sprintf('Proxy remote-user header "%s" is empty or missing.', $remoteUserHeader));
return $this->user = null;
}

Expand Down

0 comments on commit 0199ad3

Please sign in to comment.