informatikr / hedis

A Redis client library for Haskell.
http://hackage.haskell.org/package/hedis
BSD 3-Clause "New" or "Revised" License
330 stars 125 forks source link

parseConnectInfo parses the uri wrong #215

Open teto opened 1 year ago

teto commented 1 year ago

Hedis doesn't seem to interpret the redis uri like redis-cli does

expected by redis-cli -u since informatikr/hedis doesn't interpret it the same way as redis-cli (hedis will parse password as the username in redis://password@localhost while redis-cli uses it as password-) but I could not find it anywhere.

To reproduce start redis-server with something like

appendOnly no
appendfsync everysec
bind 127.0.0.1
daemonize no
databases 16
dbfilename dump.rdb
dir /var/lib/redis-test
logfile stdout
loglevel notice
maxclients 10000
port 6379
requirepass toto

Then you can connect via redis-cli -u redis://toto@localhost but passing the same redis://toto@localhost to parseConnectInfo, "toto" gets parsed as the username instead of the password.

NB: the iana link seems to be the official spec, I had a hard time finding a reference on redis docs https://github.com/redis/redis-doc/issues/2523

qnikst commented 9 months ago

Actually I'm a bit confused, according to RFC and general URI scheme authority is [user:[password]]@ and password seems deprecated according to rfc3986.

Still I see that redis upstream uses [[user:]password@ scheme. To avoid further confusion I think I'll implement spec as per https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details#uri-syntax. It looks solid and covers usual connection, TLS, sentinel.