Skip to content

Commit e5e41c7

Browse files
committed
add support for Redis 6 ACL username based authentication
- see: OpenIDC/mod_oauth2#63 - bump to 1.6.1dev Signed-off-by: Hans Zandbelt <hans.zandbelt@openidc.com>
1 parent de63a68 commit e5e41c7

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
03/04/2024
2+
- add support for Redis 6 ACL username based authentication; see: OpenIDC/mod_oauth2#63
3+
- bump to 1.6.1dev
4+
15
12/06/2023
26
- add support for the OAuth 2.0 Client Credentials grant type
37
- use libcurl version macro that works on older platforms

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([liboauth2],[1.6.0],[hans.zandbelt@openidc.com])
1+
AC_INIT([liboauth2],[1.6.1dev],[hans.zandbelt@openidc.com])
22

33
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
44
AC_CONFIG_MACRO_DIR([m4])

src/cache/redis.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef struct oauth2_cache_impl_redis_t {
3333
oauth2_ipc_mutex_t *mutex;
3434
char *host_str;
3535
oauth2_uint_t port;
36+
char *username;
3637
char *passwd;
3738
redisContext *ctx;
3839
} oauth2_cache_impl_redis_t;
@@ -68,6 +69,9 @@ static bool oauth2_cache_redis_init(oauth2_log_t *log, oauth2_cache_t *cache,
6869
v = oauth2_nv_list_get(log, options, "port");
6970
impl->port = oauth2_parse_uint(log, v, 6379);
7071

72+
v = oauth2_nv_list_get(log, options, "username");
73+
impl->username = v ? oauth2_strdup(v) : NULL;
74+
7175
v = oauth2_nv_list_get(log, options, "password");
7276
impl->passwd = v ? oauth2_strdup(v) : NULL;
7377

@@ -109,6 +113,8 @@ static bool oauth2_cache_redis_free(oauth2_log_t *log, oauth2_cache_t *cache)
109113

110114
if (impl->host_str)
111115
oauth2_mem_free(impl->host_str);
116+
if (impl->username)
117+
oauth2_mem_free(impl->username);
112118
if (impl->passwd)
113119
oauth2_mem_free(impl->passwd);
114120

@@ -227,8 +233,13 @@ static redisReply *_oauth2_cache_redis_command(oauth2_log_t *log,
227233
break;
228234

229235
if (impl->passwd != NULL) {
230-
reply =
231-
redisCommand(impl->ctx, "AUTH %s", impl->passwd);
236+
if (impl->username != NULL)
237+
reply =
238+
redisCommand(impl->ctx, "AUTH %s %s",
239+
impl->username, impl->passwd);
240+
else
241+
reply = redisCommand(impl->ctx, "AUTH %s",
242+
impl->passwd);
232243
if ((reply == NULL) ||
233244
(reply->type == REDIS_REPLY_ERROR))
234245
oauth2_error(

0 commit comments

Comments
 (0)