From: Arran Cudbard-Bell Date: Tue, 18 Oct 2022 13:31:34 +0000 (-0400) Subject: Add username to the REDIS auth command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6af0f6a2f877add850405f33fb8db4753e2582f;p=thirdparty%2Ffreeradius-server.git Add username to the REDIS auth command --- diff --git a/src/lib/redis/base.h b/src/lib/redis/base.h index e743ca8f688..7ed51d24a37 100644 --- a/src/lib/redis/base.h +++ b/src/lib/redis/base.h @@ -106,6 +106,7 @@ typedef struct { uint16_t port; //!< of Redis daemon. uint32_t database; //!< number on Redis server. + char const *username; //!< for acls. char const *password; //!< to authenticate to Redis. uint8_t max_nodes; //!< Maximum number of cluster nodes to connect to. @@ -126,6 +127,7 @@ typedef struct { { FR_CONF_OFFSET("server", FR_TYPE_STRING | FR_TYPE_REQUIRED | FR_TYPE_MULTI, fr_redis_conf_t, hostname) }, \ { FR_CONF_OFFSET("port", FR_TYPE_UINT16, fr_redis_conf_t, port), .dflt = "6379" }, \ { FR_CONF_OFFSET("database", FR_TYPE_UINT32, fr_redis_conf_t, database), .dflt = "0" }, \ + { FR_CONF_OFFSET("username", FR_TYPE_STRING, fr_redis_conf_t, username) }, \ { FR_CONF_OFFSET("password", FR_TYPE_STRING | FR_TYPE_SECRET, fr_redis_conf_t, password) }, \ { FR_CONF_OFFSET("max_nodes", FR_TYPE_UINT8, fr_redis_conf_t, max_nodes), .dflt = "20" }, \ { FR_CONF_OFFSET("max_alt", FR_TYPE_UINT32, fr_redis_conf_t, max_alt), .dflt = "3" }, \ diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index c715d2bb149..86ca4b79323 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -1472,8 +1472,17 @@ void *fr_redis_cluster_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delt } if (node->cluster->conf->password) { - DEBUG3("%s - [%i] Executing: AUTH %s", log_prefix, node->id, node->cluster->conf->password); - reply = redisCommand(handle, "AUTH %s", node->cluster->conf->password); + if (node->cluster->conf->username) { + DEBUG3("%s - [%i] Executing: AUTH %s %s", log_prefix, node->id, + node->cluster->conf->username, + node->cluster->conf->password); + reply = redisCommand(handle, "AUTH %s %s", + node->cluster->conf->username, + node->cluster->conf->password); + } else { + DEBUG3("%s - [%i] Executing: AUTH %s", log_prefix, node->id, node->cluster->conf->password); + reply = redisCommand(handle, "AUTH %s", node->cluster->conf->password); + } if (!reply) { ERROR("%s - [%i] Failed authenticating: %s", log_prefix, node->id, handle->errstr); error: