summaryrefslogtreecommitdiff
path: root/redis
diff options
context:
space:
mode:
authorLuca Cillario <luca.cillario.95@gmail.com>2022-08-30 01:07:28 +0200
committerGitHub <noreply@github.com>2022-08-30 02:07:28 +0300
commitbd0e8f26d8af5722a8b040bed6a75831bade81df (patch)
tree080326627cbf210ffb779a8420646074c6bb6d2a /redis
parentfb54bddae9d460e227bfff77724e066b4a0ca522 (diff)
downloadredis-py-bd0e8f26d8af5722a8b040bed6a75831bade81df.tar.gz
Handle auth errors for newer versions of Redis. (#2325) (#2329)
Diffstat (limited to 'redis')
-rw-r--r--redis/asyncio/connection.py11
-rwxr-xr-xredis/connection.py12
2 files changed, 22 insertions, 1 deletions
diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py
index 6823dcb..db8c240 100644
--- a/redis/asyncio/connection.py
+++ b/redis/asyncio/connection.py
@@ -87,6 +87,15 @@ MODULE_EXPORTS_DATA_TYPES_ERROR = (
"exports one or more module-side data "
"types, can't unload"
)
+# user send an AUTH cmd to a server without authorization configured
+NO_AUTH_SET_ERROR = {
+ # Redis >= 6.0
+ "AUTH <password> called without any password "
+ "configured for the default user. Are you sure "
+ "your configuration is correct?": AuthenticationError,
+ # Redis < 6.0
+ "Client sent AUTH, but no password is set": AuthenticationError,
+}
class _HiredisReaderArgs(TypedDict, total=False):
@@ -160,7 +169,9 @@ class BaseParser:
MODULE_EXPORTS_DATA_TYPES_ERROR: ModuleError,
NO_SUCH_MODULE_ERROR: ModuleError,
MODULE_UNLOAD_NOT_POSSIBLE_ERROR: ModuleError,
+ **NO_AUTH_SET_ERROR,
},
+ "WRONGPASS": AuthenticationError,
"EXECABORT": ExecAbortError,
"LOADING": BusyLoadingError,
"NOSCRIPT": NoScriptError,
diff --git a/redis/connection.py b/redis/connection.py
index 96645ba..3281b14 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -80,6 +80,15 @@ MODULE_EXPORTS_DATA_TYPES_ERROR = (
"exports one or more module-side data "
"types, can't unload"
)
+# user send an AUTH cmd to a server without authorization configured
+NO_AUTH_SET_ERROR = {
+ # Redis >= 6.0
+ "AUTH <password> called without any password "
+ "configured for the default user. Are you sure "
+ "your configuration is correct?": AuthenticationError,
+ # Redis < 6.0
+ "Client sent AUTH, but no password is set": AuthenticationError,
+}
class Encoder:
@@ -127,7 +136,6 @@ class BaseParser:
EXCEPTION_CLASSES = {
"ERR": {
"max number of clients reached": ConnectionError,
- "Client sent AUTH, but no password is set": AuthenticationError,
"invalid password": AuthenticationError,
# some Redis server versions report invalid command syntax
# in lowercase
@@ -141,7 +149,9 @@ class BaseParser:
MODULE_EXPORTS_DATA_TYPES_ERROR: ModuleError,
NO_SUCH_MODULE_ERROR: ModuleError,
MODULE_UNLOAD_NOT_POSSIBLE_ERROR: ModuleError,
+ **NO_AUTH_SET_ERROR,
},
+ "WRONGPASS": AuthenticationError,
"EXECABORT": ExecAbortError,
"LOADING": BusyLoadingError,
"NOSCRIPT": NoScriptError,