Skip to content

Commit

Permalink
avoid duplication in oauth2_jose_verify_options_jwk_set_aws_alb
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Feb 10, 2025
1 parent c60e148 commit cfbd27a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/jose.c
Original file line number Diff line number Diff line change
Expand Up @@ -1869,34 +1869,26 @@ _OAUTH_CFG_CTX_CALLBACK(oauth2_jose_verify_options_jwk_set_eckey_uri)

_OAUTH_CFG_CTX_CALLBACK(oauth2_jose_verify_options_jwk_set_aws_alb)
{
oauth2_cfg_token_verify_t *verify = (oauth2_cfg_token_verify_t *)ctx;
char *rv = NULL;
oauth2_jose_jwt_verify_ctx_t *ptr = NULL;
oauth2_cfg_token_verify_t *verify = (oauth2_cfg_token_verify_t *)ctx;
const char *alb_base_url = NULL;

oauth2_debug(log, "enter");

verify->callback = _oauth2_jose_jwt_verify_callback;
verify->ctx->callbacks = &oauth2_jose_jwt_verify_ctx_funcs;
verify->ctx->ptr = verify->ctx->callbacks->init(log);
ptr = (oauth2_jose_jwt_verify_ctx_t *)verify->ctx->ptr;

if (oauth2_jose_jwt_verify_set_options(
log, ptr, OAUTH2_JOSE_JWKS_PROVIDER_AWS_ALB, params) == false) {
rv = oauth2_strdup("oauth2_jose_jwt_verify_set_options failed");
rv = _oauth2_jose_verify_options_jwk_set_url(
log, value, params, verify, OAUTH2_JOSE_JWKS_PROVIDER_AWS_ALB,
"aws_alb");
if (rv != NULL)
goto end;
}

oauth2_jose_jwt_verify_ctx_t *ptr = verify->ctx->ptr;
ptr->jwks_provider->alb_arn = oauth2_strdup(value);

alb_base_url = oauth2_nv_list_get(log, params, "alb_base_url");
if (alb_base_url) {
ptr->jwks_provider->alb_base_url = oauth2_strdup(alb_base_url);
}

rv = oauth2_jose_options_uri_ctx(
log, value, params, ptr->jwks_provider->jwks_uri, "aws_alb");

end:

oauth2_debug(log, "leave: %s", rv);
Expand Down

0 comments on commit cfbd27a

Please sign in to comment.