Skip to content

Commit

Permalink
add support for Redis 6 ACL username based authentication
Browse files Browse the repository at this point in the history
- see: OpenIDC/mod_oauth2#63
- bump to 1.6.1dev

Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Mar 4, 2024
1 parent de63a68 commit e5e41c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([liboauth2],[1.6.0],[[email protected]])
AC_INIT([liboauth2],[1.6.1dev],[[email protected]])

AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
15 changes: 13 additions & 2 deletions src/cache/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e5e41c7

Please sign in to comment.