Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c9275a9

Browse filesBrowse files
committed
bug #43124 [Messenger] [Redis] Allow authentication with user and password (GaryPEGEOT)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Messenger] [Redis] Allow authentication with user and password | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | N/A Allow to authenticate on Redis with user **and** password, instead of only password Commits ------- 5a6bf50 [Messenger] [Redis] Allow authentication with user and password
2 parents 66e8ae9 + 5a6bf50 commit c9275a9
Copy full SHA for c9275a9

File tree

2 files changed

+16
-4
lines changed
Filter options

2 files changed

+16
-4
lines changed

‎src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,26 @@ public function testKeepGettingPendingMessages()
113113
$this->assertNotNull($connection->get());
114114
}
115115

116-
public function testAuth()
116+
/**
117+
* @param string|array $expected
118+
*
119+
* @dataProvider provideAuthDsn
120+
*/
121+
public function testAuth($expected, string $dsn)
117122
{
118123
$redis = $this->createMock(\Redis::class);
119124

120125
$redis->expects($this->exactly(1))->method('auth')
121-
->with('password')
126+
->with($expected)
122127
->willReturn(true);
123128

124-
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
129+
Connection::fromDsn($dsn, [], $redis);
130+
}
131+
132+
public function provideAuthDsn(): \Generator
133+
{
134+
yield 'Password only' => ['password', 'redis://password@localhost/queue'];
135+
yield 'User and password' => [['user', 'password'], 'redis://user:password@localhost/queue'];
125136
}
126137

127138
public function testNoAuthWithEmptyPassword()

‎src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
9797
$connectionCredentials = [
9898
'host' => $parsedUrl['host'] ?? '127.0.0.1',
9999
'port' => $parsedUrl['port'] ?? 6379,
100-
'auth' => $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
100+
// See: https://github.com/phpredis/phpredis/#auth
101+
'auth' => isset($parsedUrl['pass']) && isset($parsedUrl['user']) ? [$parsedUrl['user'], $parsedUrl['pass']] : $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
101102
];
102103

103104
if (isset($parsedUrl['query'])) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.