Skip to content

Commit 75fc950

Browse files
committed
add support for introspection.token_param_name; closes #57
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent d5e0628 commit 75fc950

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
09/13/2024
2+
- add support for introspection.token_param_name; closes #57
3+
14
09/11/2024
25
- add (optional) JQ support with caching in oauth2_jq_filter
36
- add "json_payload_claim" claim option to oauth2_cfg_target_pass_t

src/oauth2.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,27 @@ bool oauth2_http_ctx_auth_add(oauth2_log_t *log, oauth2_http_call_ctx_t *ctx,
273273

274274
_OAUTH2_CFG_CTX_TYPE_START(oauth2_introspect_ctx)
275275
oauth2_cfg_endpoint_t *endpoint;
276+
char *token_param_name;
276277
oauth2_nv_list_t *params;
277278
_OAUTH2_CFG_CTX_TYPE_END(oauth2_introspect_ctx)
278279

279280
_OAUTH2_CFG_CTX_INIT_START(oauth2_introspect_ctx)
280281
ctx->endpoint = NULL;
282+
ctx->token_param_name = NULL;
281283
ctx->params = NULL;
282284
_OAUTH2_CFG_CTX_INIT_END
283285

284286
_OAUTH2_CFG_CTX_CLONE_START(oauth2_introspect_ctx)
285287
dst->endpoint = oauth2_cfg_endpoint_clone(log, src->endpoint);
288+
dst->token_param_name = oauth2_strdup(src->token_param_name);
286289
dst->params = oauth2_nv_list_clone(log, src->params);
287290
_OAUTH2_CFG_CTX_CLONE_END
288291

289292
_OAUTH2_CFG_CTX_FREE_START(oauth2_introspect_ctx)
290293
if (ctx->endpoint)
291294
oauth2_cfg_endpoint_free(log, ctx->endpoint);
295+
if (ctx->token_param_name)
296+
oauth2_mem_free(ctx->token_param_name);
292297
if (ctx->params)
293298
oauth2_nv_list_free(log, ctx->params);
294299
_OAUTH2_CFG_CTX_FREE_END
@@ -331,7 +336,10 @@ static bool _oauth2_introspect_verify(oauth2_log_t *log,
331336
if (params == NULL)
332337
goto end;
333338

334-
oauth2_nv_list_add(log, params, OAUTH2_INTROSPECT_TOKEN, token);
339+
oauth2_nv_list_add(log, params,
340+
ctx->token_param_name ? ctx->token_param_name
341+
: OAUTH2_INTROSPECT_TOKEN,
342+
token);
335343
oauth2_nv_list_add(log, params, OAUTH2_INTROSPECT_TOKEN_TYPE_HINT,
336344
OAUTH2_INTROSPECT_TOKEN_TYPE_HINT_ACCESS_TOKEN);
337345

@@ -442,6 +450,9 @@ static char *_oauth2_verify_options_set_introspect_url_ctx(
442450
rv = oauth2_cfg_set_endpoint(log, ctx->endpoint, url, params,
443451
"introspect");
444452

453+
ctx->token_param_name = oauth2_strdup(
454+
oauth2_nv_list_get(log, params, "introspect.token_param_name"));
455+
445456
if (oauth2_parse_form_encoded_params(
446457
log, oauth2_nv_list_get(log, params, "introspect.params"),
447458
&ctx->params) == false)

0 commit comments

Comments
 (0)