redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
125 stars 60 forks source link

redis-client does not correctly auth without a username #23

Closed directionless closed 2 years ago

directionless commented 2 years ago

I tried using redis-client on heroku, and ran into some issues.

Heroku uses redis URLs that do not have a username. They look like rediss://:password@host:6379

According to the redis docs the implicit username is default.

However, when I call RedisClient.config(url: 'rediss://:password@host:6379') I get the username set to password, and not default. This causes the subsequent redis auth to fail.

I assume this is because of https://github.com/redis-rb/redis-client/blob/81460ca38fa85f97f0dc97802d919bc773ec07a7/lib/redis_client/config.rb#L125

I don't know the history there, but it seems like uri.user.empty? ? 'default' : uri.user might make more sense. (I'm not sure what the preferred style is there, and if it needs to be defensive for nil)


I (and future searchers) can work around this by manually specifying the URL. In my Heroku setup, I use:

RedisClient.config(url: ENV.fetch("REDIS_URL"), ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }, username: 'default' )
etiennebarrie commented 2 years ago

Thanks for the report! Fixed in 230f0d46fd740cb729e25af9292c4d74f2ac61a7.

directionless commented 2 years ago

Thank you for the quick fix!