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 cfccfbd6f4ad23c1a9feb44ebb91da9cd2a09734)
This commit is contained in:
Yossi Gottlieb 2020-08-18 17:13:09 +03:00 committed by Oran Agra
parent cb070accb4
commit e83d6b0cfa

View File

@ -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;