Skip to content

Commit 30da245

Browse files
committed
resolve some TODOs; valgrind; bump to 1.3.0
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
1 parent 5f565c3 commit 30da245

File tree

11 files changed

+30
-25
lines changed

11 files changed

+30
-25
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
02/26/2020
2+
- resolve some TODOs; valgrind
3+
- bump to 1.3.0
4+
15
02/25/2020
26
- change to named sessions
37

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.2.5],[hans.zandbelt@zmartzone.eu])
1+
AC_INIT([liboauth2],[1.3.0],[hans.zandbelt@zmartzone.eu])
22
AC_CONFIG_HEADERS([include/oauth2/config.h])
33

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

include/oauth2/session.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
#include "oauth2/openidc.h"
2727
#include "oauth2/util.h"
2828

29-
// TODO: this can/should be internal I guess
30-
typedef enum oauth2_cfg_session_type_t {
31-
OAUTH2_SESSION_TYPE_COOKIE,
32-
OAUTH2_SESSION_TYPE_CACHE
33-
} oauth2_cfg_session_type_t;
34-
3529
OAUTH2_CFG_TYPE_DECLARE(cfg, session)
3630
void oauth2_cfg_session_release(oauth2_log_t *log,
3731
oauth2_cfg_session_t *session);

src/cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,12 @@ oauth2_cache_t *_oauth2_cache_obtain(oauth2_log_t *log, const char *name)
269269
void oauth2_cache_release(oauth2_log_t *log, oauth2_cache_t *cache)
270270
{
271271
oauth2_cache_list_t *ptr = NULL, *prev = NULL;
272+
oauth2_uint_t refcount = cache->refcount;
272273

273274
if (cache)
274275
_oauth2_cache_free(log, cache);
275276

276-
if (cache->refcount > 0)
277+
if (refcount > 1)
277278
goto end;
278279

279280
ptr = _cache_list;

src/cfg/session_cfg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ typedef struct oauth2_cfg_session_list_t {
3232

3333
static oauth2_cfg_session_list_t *_session_list = NULL;
3434

35+
#define OAUTH2_SESSION_TYPE_COOKIE_STR "cookie"
36+
#define OAUTH2_SESSION_TYPE_CACHE_STR "cache"
37+
3538
static void _oauth2_cfg_session_register(oauth2_log_t *log, const char *name,
3639
oauth2_cfg_session_t *session)
3740
{
@@ -117,8 +120,8 @@ oauth2_cfg_session_t *_oauth2_cfg_session_obtain(oauth2_log_t *log,
117120

118121
if (_session_list == NULL) {
119122
cfg = oauth2_cfg_session_init(log);
120-
// TODO: "cookie" -> "shm"?
121-
oauth2_cfg_session_set_options(log, cfg, "cookie", NULL);
123+
oauth2_cfg_session_set_options(
124+
log, cfg, OAUTH2_SESSION_TYPE_CACHE_STR, NULL);
122125
}
123126

124127
ptr = _session_list;
@@ -272,13 +275,10 @@ _OAUTH_CFG_CTX_CALLBACK(oauth2_cfg_session_set_options_cache)
272275
return rv;
273276
}
274277

275-
#define OAUTH2_SESSION_TYPE_COOKIE_STR "cookie"
276-
#define OAUTH2_SESSION_TYPE_COOKIE_CACHE "cache"
277-
278278
// clang-format off
279279
static oauth2_cfg_set_options_ctx_t _oauth2_cfg_session_options_set[] = {
280280
{ OAUTH2_SESSION_TYPE_COOKIE_STR, oauth2_cfg_session_set_options_cookie },
281-
{ OAUTH2_SESSION_TYPE_COOKIE_CACHE, oauth2_cfg_session_set_options_cache },
281+
{ OAUTH2_SESSION_TYPE_CACHE_STR, oauth2_cfg_session_set_options_cache },
282282
{ NULL, NULL }
283283
};
284284
// clang-format on

src/cfg/target.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ void oauth2_cfg_target_pass_merge(oauth2_log_t *log,
9090
cfg->as_headers = add->as_headers != OAUTH2_CFG_FLAG_UNSET
9191
? add->as_headers
9292
: base->as_headers;
93-
// TODO: eeuhm, oauth2_strdup...??
94-
cfg->authn_header =
95-
add->authn_header != NULL ? add->authn_header : base->authn_header;
96-
cfg->prefix = add->prefix != NULL ? add->prefix : base->prefix;
97-
cfg->remote_user_claim = add->remote_user_claim != NULL
98-
? add->remote_user_claim
99-
: base->remote_user_claim;
93+
cfg->authn_header = oauth2_strdup(
94+
add->authn_header != NULL ? add->authn_header : base->authn_header);
95+
cfg->prefix =
96+
oauth2_strdup(add->prefix != NULL ? add->prefix : base->prefix);
97+
cfg->remote_user_claim = oauth2_strdup(add->remote_user_claim != NULL
98+
? add->remote_user_claim
99+
: base->remote_user_claim);
100100

101101
end:
102102

src/cfg_int.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ bool oauth2_session_save_cache(oauth2_log_t *log,
185185
const oauth2_http_request_t *request,
186186
oauth2_http_response_t *response, json_t *json);
187187

188+
typedef enum oauth2_cfg_session_type_t {
189+
OAUTH2_SESSION_TYPE_COOKIE,
190+
OAUTH2_SESSION_TYPE_CACHE
191+
} oauth2_cfg_session_type_t;
192+
188193
typedef struct oauth2_cfg_session_t {
189194
oauth2_cfg_session_type_t type;
190195
char *cookie_name;

src/openidc/openidc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ static bool _oauth2_openidc_id_token_verify(oauth2_log_t *log,
209209
char *rv = NULL;
210210
char *options = NULL;
211211

212-
// TODO: need a global in-memory jwks_uri cache
213212
oauth2_cfg_token_verify_t *verify = NULL;
214213
options = oauth2_stradd(NULL, "jwks_uri.ssl_verify", "=",
215214
provider->ssl_verify ? "true" : "false");

src/proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ bool oauth2_ropc_exec(oauth2_log_t *log, oauth2_cfg_ropc_t *cfg,
461461
username);
462462
oauth2_nv_list_add(log, params, OAUTH2_PROTO_ROPC_PASSWORD, password);
463463

464-
// TODO: sts_merge_request_parameters(log, cfg, params);
464+
// TODO: merge configurable endpoint parameters
465465

466466
ctx = oauth2_http_call_ctx_init(log);
467467
if (ctx == NULL)

src/session.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ bool oauth2_session_load_cache(oauth2_log_t *log,
189189
if (oauth2_json_decode_object(log, value, json) == false)
190190
goto end;
191191

192-
oauth2_debug(log, " #### restored: %s ###", value);
192+
oauth2_debug(log, "restored session from cache: %s##", value);
193193

194194
rc = true;
195195

@@ -223,7 +223,8 @@ bool oauth2_session_save_cache(oauth2_log_t *log,
223223
}
224224

225225
if (oauth2_cache_set(log, cfg->cache, key, value,
226-
cfg->inactivity_timeout_s) == false) {
226+
oauth2_cfg_session_inactivity_timeout_s_get(
227+
log, cfg)) == false) {
227228
oauth2_error(log, "could not store session in cache");
228229
goto end;
229230
}

0 commit comments

Comments
 (0)