Description
Symfony version(s) affected
5.4
Description
When redis sentinel cluster with non-empty auth phrase used, we may pass it in DSN as described. However, param "auth" stay ignored and not passes properly while RedisTrait::createConnection.
How to reproduce
- Ensure the redis php extension is installed
- Create a redis connection with multiple sentinel hosts and non-empty auth phrase: RedisAdapter::createConnection('redis:?host[sentinel1:26379]&host[sentinel2:26379]&host[sentinel3:26379]&redis_sentinel=mysentinel&auth=myauth')
Expected Behaviour
An instance of \Redis should be returned with a connection to the current redis master assigned by redis sentinel
Current Behaviour
After \RedisSentinel instance created without auth phrase, calling method ::getMasterAddrByName() is unable to get adress of master in cluster and it causes \Symfony\Component\Cache\Exception\InvalidArgumentException with message 'Failed to retrieve master information from sentinel "mysentinel" and dsn "redis:?host[sentinel1:26379]&host[sentinel2:26379]&host[sentinel3:26379]&redis_sentinel=mysentinel&auth=myauth".'
Possible Solution
phpredis extension supports passing auth as argument of \RedisSentinel::__consruct(), so it probably should be passed if it present in DSN.
also param auth should be passed in such trait while \Redis::connect(), as described to avoid RedisException: NOAUTH Authentication required, for example when you later want some $redis->eval(...),