From aaeb84647750ace19639c8275e3fa089c7696073 Mon Sep 17 00:00:00 2001 From: PHAS Developer <110562019+phasdev@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:41:18 +0000 Subject: [PATCH 1/2] [Security] Return null instead of empty username to fix deprecation notice --- .../Security/Http/Authenticator/RemoteUserAuthenticator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php index 140b6c271efbe..96890e1aacf89 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php @@ -45,6 +45,6 @@ protected function extractUsername(Request $request): ?string throw new BadCredentialsException(sprintf('User key was not found: "%s".', $this->userKey)); } - return $request->server->get($this->userKey); + return $request->server->get($this->userKey) ?: null; } } From d80071cfc0a07bb8486ad08183248c380b218ded Mon Sep 17 00:00:00 2001 From: PHAS Developer <110562019+phasdev@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:35:37 +0000 Subject: [PATCH 2/2] [Security] Return null instead of empty username to fix deprecation notice --- .../Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php index 5119f8ce09e74..f16ea197de5df 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php @@ -36,6 +36,7 @@ public function testSupportNoUser() $authenticator = new RemoteUserAuthenticator(new InMemoryUserProvider(), new TokenStorage(), 'main'); $this->assertFalse($authenticator->supports($this->createRequest([]))); + $this->assertFalse($authenticator->supports($this->createRequest(['REMOTE_USER' => '']))); } public function testSupportTokenStorageWithToken() @@ -63,7 +64,7 @@ public function testAuthenticate(InMemoryUserProvider $userProvider, RemoteUserA $passport = $authenticator->authenticate($request); $this->assertTrue($user->isEqualTo($passport->getUser())); } - + public static function provideAuthenticators() { $userProvider = new InMemoryUserProvider();