Skip to content

Commit 9abe1fd

Browse files
committed
release 1.3.0 additions
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
1 parent 30da245 commit 9abe1fd

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ check_liboauth2_SOURCES = \
189189
test/check_proto.c \
190190
test/check_oauth2.c \
191191
test/check_openidc.c \
192-
test/server_stubs.c
192+
test/server_stubs.c \
193+
test/provider.json
193194
if HAVE_APACHE
194195
check_liboauth2_SOURCES += \
195196
test/check_apache.c

src/cache.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static void _oauth2_cache_register(oauth2_log_t *log, const char *name,
227227
{
228228
oauth2_cache_list_t *ptr = NULL, *prev = NULL;
229229

230+
oauth2_debug(log, "enter: %s", name);
231+
230232
ptr = oauth2_mem_alloc(sizeof(oauth2_cache_list_t));
231233
ptr->name = oauth2_strdup(name);
232234
ptr->cache = cache;
@@ -239,15 +241,22 @@ static void _oauth2_cache_register(oauth2_log_t *log, const char *name,
239241
} else {
240242
_cache_list = ptr;
241243
}
244+
245+
oauth2_debug(log, "leave");
242246
}
243247

244248
oauth2_cache_t *_oauth2_cache_obtain(oauth2_log_t *log, const char *name)
245249
{
250+
oauth2_cache_t *rv = NULL;
246251
oauth2_cache_list_t *ptr = NULL, *result = NULL;
247252

253+
oauth2_debug(log, "enter: %s", name);
254+
248255
if (_cache_list == NULL) {
249-
oauth2_cache_init(log, NULL, NULL);
250-
oauth2_cache_post_config(log, _cache_list->cache);
256+
if (oauth2_cache_init(log, NULL, NULL) == NULL)
257+
goto end;
258+
if (oauth2_cache_post_config(log, _cache_list->cache) == false)
259+
goto end;
251260
}
252261

253262
ptr = _cache_list;
@@ -263,16 +272,27 @@ oauth2_cache_t *_oauth2_cache_obtain(oauth2_log_t *log, const char *name)
263272
ptr = ptr->next;
264273
}
265274

266-
return result ? oauth2_cache_clone(log, result->cache) : NULL;
275+
rv = result ? oauth2_cache_clone(log, result->cache) : NULL;
276+
277+
end:
278+
279+
oauth2_debug(log, "leave: %p", rv);
280+
281+
return rv;
267282
}
268283

269284
void oauth2_cache_release(oauth2_log_t *log, oauth2_cache_t *cache)
270285
{
271286
oauth2_cache_list_t *ptr = NULL, *prev = NULL;
272-
oauth2_uint_t refcount = cache->refcount;
287+
oauth2_uint_t refcount = 0;
273288

274-
if (cache)
275-
_oauth2_cache_free(log, cache);
289+
oauth2_debug(log, "enter");
290+
291+
if (cache == NULL)
292+
goto end;
293+
294+
refcount = cache->refcount;
295+
_oauth2_cache_free(log, cache);
276296

277297
if (refcount > 1)
278298
goto end;
@@ -296,13 +316,17 @@ void oauth2_cache_release(oauth2_log_t *log, oauth2_cache_t *cache)
296316

297317
end:
298318

319+
oauth2_debug(log, "return");
320+
299321
return;
300322
}
301323

302324
bool oauth2_cache_post_config(oauth2_log_t *log, oauth2_cache_t *cache)
303325
{
304326
bool rc = false;
305327

328+
oauth2_debug(log, "enter");
329+
306330
if ((cache == NULL) || (cache->type == NULL))
307331
goto end;
308332

@@ -315,6 +339,8 @@ bool oauth2_cache_post_config(oauth2_log_t *log, oauth2_cache_t *cache)
315339

316340
end:
317341

342+
oauth2_debug(log, "return: %d", rc);
343+
318344
return rc;
319345
}
320346

@@ -420,7 +446,7 @@ bool oauth2_cache_set(oauth2_log_t *log, oauth2_cache_t *cache, const char *key,
420446
"enter: key=%s, len=%lu, ttl(s)=" OAUTH2_TIME_T_FORMAT
421447
", type=%s, encrypt=%d",
422448
key, value ? (unsigned long)strlen(value) : 0, ttl_s,
423-
cache && cache->type ? cache->type->name : "<n/a>",
449+
(cache && cache->type) ? cache->type->name : "<n/a>",
424450
cache ? cache->encrypt : -1);
425451

426452
if ((cache == NULL) || (cache->type == NULL) ||

src/openidc/resolver.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool _oauth2_openidc_provider_resolve(oauth2_log_t *log,
149149
goto end;
150150
}
151151

152-
if (issuer) {
152+
if ((issuer) && (cfg->provider_resolver->cache)) {
153153

154154
oauth2_cache_get(log, cfg->provider_resolver->cache, issuer,
155155
&s_json);
@@ -176,9 +176,12 @@ bool _oauth2_openidc_provider_resolve(oauth2_log_t *log,
176176
goto end;
177177

178178
// TODO: cache expiry configuration option
179-
oauth2_cache_set(log, cfg->provider_resolver->cache,
180-
oauth2_openidc_provider_issuer_get(log, *provider),
181-
s_json, OAUTH_OPENIDC_PROVIDER_CACHE_EXPIRY_DEFAULT);
179+
if (cfg->provider_resolver->cache) {
180+
oauth2_cache_set(
181+
log, cfg->provider_resolver->cache,
182+
oauth2_openidc_provider_issuer_get(log, *provider), s_json,
183+
OAUTH_OPENIDC_PROVIDER_CACHE_EXPIRY_DEFAULT);
184+
}
182185

183186
rc = true;
184187

test/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ WORKDIR ${SRCDIR}
3838
ENV LD_LIBRARY_PATH ${SRCDIR}/.libs
3939
ENV CK_FORK "no"
4040

41+
RUN sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf
42+
4143
RUN echo "#!/bin/sh" >> ./start.sh
4244
RUN echo "service memcached start" >> ./start.sh
4345
RUN echo "service redis-server start" >> ./start.sh

0 commit comments

Comments
 (0)