diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc index 7a93f4a2602..c7f742656d0 100644 --- a/src/commands/cmd_server.cc +++ b/src/commands/cmd_server.cc @@ -1329,7 +1329,7 @@ class CommandPollUpdates : public Commander { Format format_ = Format::Raw; }; -REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only ok-loading", NO_KEY), +REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only ok-loading auth", NO_KEY), MakeCmdAttr("ping", -1, "read-only", NO_KEY), MakeCmdAttr("select", 2, "read-only", NO_KEY), MakeCmdAttr("info", -1, "read-only ok-loading", NO_KEY), @@ -1354,7 +1354,7 @@ REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only o MakeCmdAttr("time", 1, "read-only ok-loading", NO_KEY), MakeCmdAttr("disk", 3, "read-only", 2, 2, 1), MakeCmdAttr("memory", 3, "read-only", 2, 2, 1), - MakeCmdAttr("hello", -1, "read-only ok-loading", NO_KEY), + MakeCmdAttr("hello", -1, "read-only ok-loading auth", NO_KEY), MakeCmdAttr("restore", -4, "write", 1, 1, 1), MakeCmdAttr("compact", 1, "read-only no-script", NO_KEY), diff --git a/src/commands/commander.h b/src/commands/commander.h index bb5674dbf86..f0589c92c42 100644 --- a/src/commands/commander.h +++ b/src/commands/commander.h @@ -81,6 +81,8 @@ enum CommandFlags : uint64_t { // "blocking" flag, for commands that don't perform db ops immediately, // but block and wait for some event to happen before performing db ops kCmdBlocking = 1ULL << 14, + // "auth" flag, for commands used for authentication + kCmdAuth = 1ULL << 15, }; enum class CommandCategory : uint8_t { @@ -329,6 +331,8 @@ inline uint64_t ParseCommandFlags(const std::string &description, const std::str flags |= kCmdNoDBSizeCheck; else if (flag == "slow") flags |= kCmdSlow; + else if (flag == "auth") + flags |= kCmdAuth; else if (flag == "blocking") { flags |= kCmdBlocking; diff --git a/src/server/redis_connection.cc b/src/server/redis_connection.cc index e45951b7548..2e4ed68c552 100644 --- a/src/server/redis_connection.cc +++ b/src/server/redis_connection.cc @@ -397,7 +397,7 @@ void Connection::ExecuteCommands(std::deque *to_process_cmds) { if (GetNamespace().empty()) { if (!password.empty()) { - if (cmd_name != "auth" && cmd_name != "hello") { + if (!(cmd_flags & kCmdAuth)) { Reply(redis::Error({Status::RedisNoAuth, "Authentication required."})); continue; }