Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Nov 2, 2024
1 parent bd0cdbf commit 55d681d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fakeredis/commands_mixins/acl_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ def auth(self, *args: bytes) -> bytes:
if not 1 <= len(args) <= 2:
raise SimpleError(msgs.WRONG_ARGS_MSG6.format("AUTH"))
username = None if len(args) == 1 else args[0]
password = args[1] if len(args) == 2 else None
if (
(username is None or username == b"default")
and b"requirepass" in self._server_config
and password == self._server_config[b"requirepass"]
):
password = args[1] if len(args) == 2 else args[0]
if (username is None or username == b"default") and (password == self._server_config.get(b"requirepass", None)):
return OK
if len(args) >= 1 and self._check_user_password(username, password):
return OK
Expand Down
2 changes: 2 additions & 0 deletions fakeredis/model/_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def set_nopass(self) -> None:
def check_password(self, password: Optional[bytes]) -> bool:
if self._nopass and not password:
return True
if not password:
return False
password_hex = hashlib.sha256(password).hexdigest().encode()
return password_hex in self._passwords and self._enabled

Expand Down

0 comments on commit 55d681d

Please sign in to comment.