Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Return null instead of empty username to fix deprecation notice #59586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at how the method is used I wonder if we shouldn’t throw a BadCredentialsException here then.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();
Expand Down