summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Scott <5336227+IAmATeaPot418@users.noreply.github.com>2019-10-21 01:41:41 -0700
committerAndy McCurdy <andy@andymccurdy.com>2019-12-28 22:23:43 -0800
commit4db7399b83c0ebc0e1a46e053b755686ace91c5b (patch)
tree1a4b8fca84529afff162bc0484a7381d24ed401b
parent4047cac77e5b202f302d534c8f974423cf96f3e8 (diff)
downloadredis-py-4db7399b83c0ebc0e1a46e053b755686ace91c5b.tar.gz
Add support for hashed passwords
-rwxr-xr-xredis/client.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/redis/client.py b/redis/client.py
index 9d51558..14a37e7 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -972,12 +972,14 @@ class Redis(object):
``add_passwords`` if specified is a list of new passwords that this
user can authenticate with. For convenience, the value of
``add_passwords`` can also be a simple string when adding a single
- password. Note: Do not prefix passwords with '>'.
+ password. Note: Do not prefix passwords with '>' or '#'.
+ Passwords can not be 64 characters unless in hash form.
``remove_passwords`` if specified is a list of passwords to remove from
this user. For convenience, the value of ``remove_passwords`` can also
be a simple string when removing a single password. Note: Do not
- prefix passwords with '<'.
+ prefix passwords with '<' or '!'.
+ Passwords can not be 64 characters unless in hash form.
``categories`` if specified is a list of strings representing category
permissions. Each string must be prefixed with either a "+@" or "-@"
@@ -1014,14 +1016,20 @@ class Redis(object):
# to be specified as a simple string or a list
remove_passwords = list_or_args(remove_passwords, [])
for password in remove_passwords:
- pieces.append('<%s' % password)
+ if len(password) == 64:
+ pieces.append('!%s' % password)
+ else:
+ pieces.append('<%s' % password)
if add_passwords:
# as most users will have only one password, allow add_passwords
# to be specified as a simple string or a list
add_passwords = list_or_args(add_passwords, [])
for password in add_passwords:
- pieces.append('>%s' % password)
+ if len(password) == 64:
+ pieces.append('#%s' % password)
+ else:
+ pieces.append('<%s' % password)
if nopass:
pieces.append(b'nopass')