alisaifee / limits

Rate limiting using various strategies and storage backends such as redis & memcached
https://limits.readthedocs.org
MIT License
423 stars 58 forks source link

RedisCluster does not work with password in uri #153

Closed gerrymanoim closed 1 year ago

gerrymanoim commented 1 year ago

Repro:

uri = "redis+cluster://:testpassword@host:123,host:456"
RedisClusterStorage(uri=uri)

will throw:

limits/storage/redis_cluster.py in __init__(self, uri, **options)
     53         cluster_hosts = []
     54         for loc in parsed.netloc.split(","):
---> 55             host, port = loc.split(":")
     56             cluster_hosts.append((host, int(port)))
     57 

ValueError: too many values to unpack (expected 2)

I think this is because the netloc will include the password piece and fail to parse then when splitting.

limits version 3.1.5, python 3.9.

alisaifee commented 1 year ago

Thanks for the report! Looks like this has been broken since it was introduced.

alisaifee commented 1 year ago

This is now fixed in master and available in the 3.2.0 release.

gerrymanoim commented 1 year ago

Amazing - thanks!