From 0816b8fadd3cba0e49418452842f0d5c97a2040f Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Tue, 18 Aug 2020 17:13:09 +0300 Subject: [PATCH] Module API: Fail ineffective auth calls. The client pointed to by the module context may in some cases be a fake client. RM_Authenticate*() calls in this case would be ineffective but appear to succeed, and this change fails them to make it easier to catch such cases. (cherry picked from commit 82866776d0c26f17043f9c1b0f0f5f48660e6848) --- src/module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/module.c b/src/module.c index bfe7d6886..65d22b713 100644 --- a/src/module.c +++ b/src/module.c @@ -5638,6 +5638,11 @@ static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModu return REDISMODULE_ERR; } + /* Avoid settings which are meaningless and will be lost */ + if (!ctx->client || (ctx->client->flags & CLIENT_MODULE)) { + return REDISMODULE_ERR; + } + moduleNotifyUserChanged(ctx->client); ctx->client->user = user;