From b0b65c3f04fb72f59fa5aeddb81ea479661ac898 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 1 Jan 2023 14:52:46 +0100 Subject: [PATCH] Fix https://github.com/firefly-iii/firefly-iii/issues/6788 --- app/Support/Authentication/RemoteUserGuard.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php index 2aaaaa5d05..1086ddaa58 100644 --- a/app/Support/Authentication/RemoteUserGuard.php +++ b/app/Support/Authentication/RemoteUserGuard.php @@ -39,14 +39,14 @@ use Log; class RemoteUserGuard implements Guard { protected Application $application; - protected $provider; - protected $user; + protected $provider; + protected $user; /** * Create a new authentication guard. * - * @param UserProvider $provider - * @param Application $app + * @param UserProvider $provider + * @param Application $app */ // @phpstan-ignore-next-line public function __construct(UserProvider $provider, Application $app) // @phpstan-ignore-line @@ -62,7 +62,8 @@ class RemoteUserGuard implements Guard /** * @return bool */ - public function viaRemember(): bool { + public function viaRemember(): bool + { Log::debug(sprintf('Now at %s', __METHOD__)); return false; } @@ -80,7 +81,10 @@ class RemoteUserGuard implements Guard } // Get the user identifier from $_SERVER or apache filtered headers $header = config('auth.guard_header', 'REMOTE_USER'); - $userID = request()->server($header) ?? apache_request_headers()[$header] ?? null; + $userID = request()->server($header) ?? null; + if (function_exists('apache_request_headers')) { + $userID = request()->server($header) ?? apache_request_headers()[$header] ?? null; + } if (null === $userID) { Log::error(sprintf('No user in header "%s".', $header)); throw new FireflyException('The guard header was unexpectedly empty. See the logs.'); @@ -93,7 +97,7 @@ class RemoteUserGuard implements Guard $header = config('auth.guard_email'); if (null !== $header) { - $emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null); + $emailAddress = (string)(request()->server($header) ?? apache_request_headers()[$header] ?? null); $preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email'); if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {