ngx_addon_name=ngx_http_auth_jwt_module

# --- submodule: nxe-json ---
nxe_json_dir="$ngx_addon_dir/nxe-json"

if [ ! -f "$nxe_json_dir/config.ngx" ]; then
    echo "$0: error: $nxe_json_dir/config.ngx not found" >&2
    exit 1
fi

. "$nxe_json_dir/config.ngx"

# --- submodule: nxe-jwx ---
nxe_jwx_dir="$ngx_addon_dir/nxe-jwx"

if [ ! -f "$nxe_jwx_dir/config.ngx" ]; then
    echo "$0: error: $nxe_jwx_dir/config.ngx not found" >&2
    exit 1
fi

# Enable HMAC (HS256/384/512) and oct keys.  This module is the only
# upstream consumer that exposes auth_jwt_keyval and HMAC-based JWTs,
# so HMAC support is compiled in here (other modules leave it off).
CFLAGS="$CFLAGS -DNXE_JWX_HAVE_HMAC"

. "$nxe_jwx_dir/config.ngx"

# --- module definition ---
ngx_module_type=HTTP
ngx_module_name=ngx_http_auth_jwt_module
ngx_module_deps="$nxe_json_module_deps $nxe_jwx_module_deps"
ngx_module_incs="$nxe_json_module_incs $nxe_jwx_module_incs"
ngx_module_srcs="\
  $nxe_json_module_srcs \
  $nxe_jwx_module_srcs \
  $ngx_addon_dir/src/ngx_auth_jwt_claims.c \
  $ngx_addon_dir/src/ngx_auth_jwt_field.c \
  $ngx_addon_dir/src/ngx_auth_jwt_operator.c \
  $ngx_addon_dir/src/ngx_http_auth_jwt_module.c"
ngx_module_libs="$nxe_json_module_libs $nxe_jwx_module_libs -lssl"

. auto/module
