From da977d071025d67a0a176c22f5ee2f703ff728c8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 4 Feb 2024 15:10:10 +0900 Subject: [PATCH] redis: Add username Redis introduced ACL feature in 4.0.0, and this feature is supported by redis-py since 3.4.0[1]. When ACL is enabled, authentication requires username in addition to password. [1] https://github.com/redis/redis-py/commit/8df8cd54d135380ad8b3b8807a67a3e6915b0b49 Closes-Bug: #2052371 Change-Id: I9b53c3a314dcffbe49535799ba6d7a1fdddb8d84 --- setup.cfg | 2 +- tooz/drivers/redis.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index e8ab541f..ed9ca8f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,7 +53,7 @@ etcd3gw = zake = zake>=0.1.6 # Apache-2.0 redis = - redis>=3.1.0 # MIT + redis>=3.4.0 # MIT postgresql = psycopg2>=2.5 # LGPL/ZPL mysql = diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 9b2ef031..51dbf080 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -159,7 +159,8 @@ class RedisDriver(coordination.CoordinationDriverCachedRunWatchers, The Redis driver connection URI should look like:: - redis://[:PASSWORD@]HOST:PORT[?OPTION=VALUE[&OPTION2=VALUE2[&...]]] + redis://[USERNAME:PASSWORD@]HOST:PORT + [?OPTION=VALUE[&OPTION2=VALUE2[&...]]] For a list of options recognized by this driver, see the documentation for the member CLIENT_ARGS, and to determine the expected types of those @@ -428,6 +429,8 @@ return 1 if not parsed_url.path: raise ValueError("Expected socket path in parsed urls path") kwargs['unix_socket_path'] = parsed_url.path + if parsed_url.username: + kwargs['username'] = parsed_url.username if parsed_url.password: kwargs['password'] = parsed_url.password for a in cls.CLIENT_ARGS: