Remote user guard accepts custom header

This commit is contained in:
James Cole 2020-07-31 06:21:53 +02:00
parent 77658d19dd
commit 981960fcb4
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -69,16 +69,13 @@ class RemoteUserGuard implements Guard
return;
}
// Get the user identifier from $_SERVER
$userID = request()->server('REMOTE_USER') ?? null;
$header = config('auth.guard_header', 'REMOTE_USER');
$userID = request()->server($header) ?? null;
if (null === $userID) {
Log::debug('No user in REMOTE_USER.');
throw new FireflyException('The REMOTE_USER header was unexpectedly empty.');
Log::error(sprintf('No user in header "%s".', $header));
throw new FireflyException('The guard header was unexpectedly empty. See the logs.');
}
// do some basic debugging here:
// $userID = 'test@firefly';
/** @var User $user */
$user = $this->provider->retrieveById($userID);