Skip to content

[Messenger] Fix Redis Transport when username is empty #43484

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

Merged
merged 1 commit into from
Oct 24, 2021
Merged
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 @@ -133,6 +133,9 @@ public function provideAuthDsn(): \Generator
{
yield 'Password only' => ['password', 'redis://password@localhost/queue'];
yield 'User and password' => [['user', 'password'], 'redis://user:password@localhost/queue'];
yield 'User and colon' => ['user', 'redis://user:@localhost/queue'];
yield 'Colon and password' => ['password', 'redis://:password@localhost/queue'];
yield 'Colon and falsy password' => ['0', 'redis://:0@localhost/queue'];
}

public function testNoAuthWithEmptyPassword()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;
$consumer = $pathParts[3] ?? $redisOptions['consumer'] ?? null;
$pass = '' !== ($parsedUrl['pass'] ?? '') ? $parsedUrl['pass'] : null;
$user = '' !== ($parsedUrl['user'] ?? '') ? $parsedUrl['user'] : null;

$connectionCredentials = [
'host' => $parsedUrl['host'] ?? '127.0.0.1',
'port' => $parsedUrl['port'] ?? 6379,
// See: https://github.com/phpredis/phpredis/#auth
'auth' => isset($parsedUrl['pass']) && isset($parsedUrl['user']) ? [$parsedUrl['user'], $parsedUrl['pass']] : $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
'auth' => null !== $pass && null !== $user ? [$user, $pass] : ($pass ?? $user),
];

if (isset($parsedUrl['query'])) {
Expand Down