diff --git a/src/database-redis.cpp b/src/database-redis.cpp index 3df18694..93e6717f 100644 --- a/src/database-redis.cpp +++ b/src/database-redis.cpp @@ -53,6 +53,18 @@ Database_Redis::Database_Redis(Settings &conf) redisFree(ctx); throw DatabaseException(err); } + if (conf.exists("redis_password")) { + tmp = conf.get("redis_password"); + redisReply *reply = static_cast(redisCommand(ctx, "AUTH %s", tmp.c_str())); + if (!reply) + throw DatabaseException("Redis authentication failed"); + if (reply->type == REDIS_REPLY_ERROR) { + std::string err = "Redis authentication failed: " + std::string(reply->str, reply->len); + freeReplyObject(reply); + throw DatabaseException(err); + } + freeReplyObject(reply); + } } Database_Redis::~Database_Redis()