From e5e41c72fb0a7e4633778cb87c1c37736f1fe085 Mon Sep 17 00:00:00 2001 From: Hans Zandbelt Date: Mon, 4 Mar 2024 21:48:34 +0100 Subject: [PATCH] add support for Redis 6 ACL username based authentication - see: OpenIDC/mod_oauth2#63 - bump to 1.6.1dev Signed-off-by: Hans Zandbelt --- ChangeLog | 4 ++++ configure.ac | 2 +- src/cache/redis.c | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1200809..adb1873 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +03/04/2024 +- add support for Redis 6 ACL username based authentication; see: OpenIDC/mod_oauth2#63 +- bump to 1.6.1dev + 12/06/2023 - add support for the OAuth 2.0 Client Credentials grant type - use libcurl version macro that works on older platforms diff --git a/configure.ac b/configure.ac index 833a730..78f223c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([liboauth2],[1.6.0],[hans.zandbelt@openidc.com]) +AC_INIT([liboauth2],[1.6.1dev],[hans.zandbelt@openidc.com]) AM_INIT_AUTOMAKE([foreign no-define subdir-objects]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/src/cache/redis.c b/src/cache/redis.c index b5ac124..9baafb3 100644 --- a/src/cache/redis.c +++ b/src/cache/redis.c @@ -33,6 +33,7 @@ typedef struct oauth2_cache_impl_redis_t { oauth2_ipc_mutex_t *mutex; char *host_str; oauth2_uint_t port; + char *username; char *passwd; redisContext *ctx; } oauth2_cache_impl_redis_t; @@ -68,6 +69,9 @@ static bool oauth2_cache_redis_init(oauth2_log_t *log, oauth2_cache_t *cache, v = oauth2_nv_list_get(log, options, "port"); impl->port = oauth2_parse_uint(log, v, 6379); + v = oauth2_nv_list_get(log, options, "username"); + impl->username = v ? oauth2_strdup(v) : NULL; + v = oauth2_nv_list_get(log, options, "password"); impl->passwd = v ? oauth2_strdup(v) : NULL; @@ -109,6 +113,8 @@ static bool oauth2_cache_redis_free(oauth2_log_t *log, oauth2_cache_t *cache) if (impl->host_str) oauth2_mem_free(impl->host_str); + if (impl->username) + oauth2_mem_free(impl->username); if (impl->passwd) oauth2_mem_free(impl->passwd); @@ -227,8 +233,13 @@ static redisReply *_oauth2_cache_redis_command(oauth2_log_t *log, break; if (impl->passwd != NULL) { - reply = - redisCommand(impl->ctx, "AUTH %s", impl->passwd); + if (impl->username != NULL) + reply = + redisCommand(impl->ctx, "AUTH %s %s", + impl->username, impl->passwd); + else + reply = redisCommand(impl->ctx, "AUTH %s", + impl->passwd); if ((reply == NULL) || (reply->type == REDIS_REPLY_ERROR)) oauth2_error(