I am trying to use NGINX auth_request and NJS to validate the OAuth token. I also want to validate the token based on the parent request's $request_method
, but I am not able to get the original request's method. Instead I am receiving the internal auth request's method and URI.
Requested method is GET /_oauth2_token_introspection
Is there any way to get the original request's $request_method
and $request_uri
. I referred to https://github.com/nginx/njs-examples/blob/master/README.rst#authorizing-requests-using-auth_request-httpauthorizationauth_request but the "r.method" is always GET even if the original parent request is PUT/POST.
I also tried to send it using headers and read it in NJS code, but it is always "undefined"
location = /_oauth2_token_introspection {
internal;
proxy_set_header Content-Length "";
proxy_pass_request_headers on;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-METHOD $request_method;
js_content oauth2.introspectAccessToken;
}
Can someone help me in this regard
Using
r.variables.request_uri
andr.variables.request_method
in my NJS script worked for me. For more details, refer https://github.com/nginx/njs/issues/100