Skip to content

Commit

Permalink
ACL WHOAMI
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Nov 3, 2024
1 parent d31ec72 commit 6cdbf7d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fakeredis/commands_mixins/acl_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init(self, *args: Any, **kwargs: Any) -> None:
super(AclCommandsMixin).__init__(*args, **kwargs)
self.version: Tuple[int]
self._server: Any
self._current_user: bytes = b"default"

@property
def _server_config(self) -> Dict[bytes, bytes]:
Expand Down Expand Up @@ -42,8 +43,10 @@ def auth(self, *args: bytes) -> bytes:
username = None if len(args) == 1 else args[0]
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)):
self._current_user = b"default"
return OK
if len(args) >= 1 and self._check_user_password(username, password):
self._current_user = username
return OK
raise SimpleError(msgs.AUTH_FAILURE)

Expand Down Expand Up @@ -134,7 +137,7 @@ def acl_users(self) -> List[bytes]:

@command(name="ACL WHOAMI", fixed=(), repeat=())
def acl_whoami(self) -> bytes:
return b"default" # TODO
return self._current_user

@command(name="ACL SAVE", fixed=(), repeat=())
def acl_save(self) -> SimpleString:
Expand Down

0 comments on commit 6cdbf7d

Please sign in to comment.