Welcome! Log In Create A New Profile

Advanced

Access original request whn in njs aut_request

Posted by dcore94 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Access original request whn in njs aut_request
April 20, 2021 12:15PM
Hello.
I am trying to access the original request, method and host header from inside an njs module I developed in order to make a PEP in combination with auth_request.
But however I try, I always get the internal request (/pep) and method (always GET). I'm also unable to pass information with extra-headers as in the pep2 location example ...
I also tried with r.parent but it is undefined...
How should I do this? I want to gather claims inside my script to use for authorizations.
Thank you.

The conf ...

location / {
auth_request /pep;
proxy_pass http://_internal-server;
}

location = /pep {
js_content authz.enforce;
}

location = /pep2 {
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
js_content authz.enforce;
}

The js code ....
export default { enforce };
function enforce(r) {
r.error("Inside NJS enforce " + njs.dump(r))
}

Online Users

Guests: 71
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready