From cfccfbd6f4ad23c1a9feb44ebb91da9cd2a09734 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. --- src/module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/module.c b/src/module.c index 2de7f60ed..615a5223f 100644 --- a/src/module.c +++ b/src/module.c @@ -5639,6 +5639,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;