<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Hi Sergey,<br />
<br />
Sure.  The tool that I’m using for HTTP testing is just a GUI interface directly to HTTP so it works the same as a browser would since it’s just straight HTTP.  It supports curl mode too but that’s just a alternative wrapper for HTTP and none of the methods that we’re using to interface with this via POST (including direct browser POST) are producing different results.<br />
<br />
I realize that the implementation in the access function right now makes no sense.  This is just a stripped down version of where this will eventually go specifically for the sake of testing POST args access.  I get the same results even if we remove the r.internalRedirect statement.<br />
<br />
dbadmin.js<br />
<span style="color:#cd8d4e;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">function</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px"> </span><span style="color:#a97a8c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">access</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">(</span><em style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">r</em><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">){ </span><span style="font-size: 12px"><br /></span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">    </span><span style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">r</span><span style="color:#c4bc3c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">.</span><span style="color:#a97a8c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">return</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">(</span><span style="color:#5286b7;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">200</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">, </span><span style="color:#d19a66;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">JSON</span><span style="color:#c4bc3c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">.</span><span style="color:#d1673a;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">stringify</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">(</span><span style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">r</span><span style="color:#c4bc3c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">.</span><span style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">args</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">));</span><span style="font-size: 12px"><br /></span><span style="font-size: 12px"><br /></span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">    </span><span style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">r</span><span style="color:#c4bc3c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">.</span><span style="color:#a97a8c;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">internalRedirect</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">(</span><span style="color:#b9c87f;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">'@php'</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">);</span><span style="font-size: 12px"><br /></span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">}</span><span style="font-size: 12px"><br /></span><span style="font-size: 12px"><br /></span><span style="color:#cd8d4e;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">export</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px"> </span><span style="color:#cd8d4e;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">default</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px"> {</span><span style="color:#d9dbfc;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">access</span><span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">}</span><span style="font-size: 12px"><br /></span><span style="font-size: 12px"><br /></span><span style="color:#ffffff;background-color:#383939">The location block for the config file:</span><br />
# Pass PHP requests to PHP-FPM<br />
location ~ \.php$ {<br />
<span style="white-space:pre">  limit_req zone=post_limit burst=5 nodelay;</span><br />
<span style="white-space:pre">  limit_req_status 429;</span><br />
<br />
<span style="white-space:pre">  add_header Content-Type text/plain;</span><br />
<span style="white-space:pre">  js_content dbadmin.access;</span><br />
}<br />
<br />
location @php{<br />
<span style="white-space:pre">  set $no_cache 1;</span><br />
<span style="white-space:pre">  include includes/fastcgi.conf;</span><br />
<br />
<span style="white-space:pre">  fastcgi_pass unix:/var/run/php-fpm/dbadmin.sock;</span><br />
<span style="white-space:pre">  # fastcgi_cache dbadmin;</span><br />
}<br />
<br />
The relevant import directive from nginx.conf<br />
<span style="color:#ffffff;background-color:#383939;font-family:Menlo, Monaco, Courier New, monospace;font-size: 12px">js_import scripts/security/dbadmin.js;</span><span style="font-size: 12px"><br /></span><span style="font-size: 12px"><br /></span><span style="font-size: 12px"><br /></span><span style="color:#ffffff;background-color:#383939">Incidentally, this config also illustrates why I was asking about access phase filters.  In LuaJIT/OpenResty, we can tap into the access phase to deny a request without having to define a separate location block to internalRedirect to.   It seems like the only way to simulate this with NJS right now is to define a location, use js_content to hand off to NJS for content, and then internalRedirect or sub request to a different location block to allow requests through.  It’s simpler if there is just a way to control access in the access phase without having to use a workaround in the content phase to try to add access control first and then run the content phase normally.</span><br />
<br />
<span style="color:#ffffff;background-color:#383939">In any case, I also wanted to confirm that the curl method of doing the POST doesn’t really change anything as well.  Here’s a screenshot along with the corresponding curl request that the app runs.</span><br />
<a href="https://share.wordkeeper.com/n4SEbeW3mUqZXtejjXsS" target="_blank">https://share.wordkeeper.com/n4SEbeW3mUqZXtejjXsS</a></div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont"><br />
--<br />
Lance Dockins<br />
Minister of Magic<br />
WordKeeper<br />
Office: 405.585.2500<br />
Cell: 405.306.7401<br />
https://wordkeeper.com</div>
</div>
<div name="messageReplySection">On Aug 11, 2021, 9:20 PM -0500, Sergey A. Osokin <osa@freebsd.org.ru>, wrote:<br />
<blockquote type="cite" style="border-left-color: grey; border-left-width: thin; border-left-style: solid; margin: 5px 5px;padding-left: 10px;">Hi Lance,<br />
<br />
On Wed, Aug 11, 2021 at 09:05:32PM -0500, Lance Dockins wrote:<br />
<blockquote type="cite">Hi Sergey,<br />
<br />
Thank you.  Perhaps something is going wrong with the implementation<br />
of r.args that we’re using.  I’m just getting an empty JS object for<br />
POST vars.  Args only seems to work for query string vars for me.<br />
<br />
Here’s the key config info.<br />
<br />
In the location block for the route that I’m testing:<br />
<br />
add_header Content-Type text/plain;<br />
js_content dbadmin.access;<br />
<br />
The dbadmin.access function just has this at the top of the function right now:<br />
r.return(200, JSON.stringify(r.args));<br /></blockquote>
<br />
Could you please share a couple of things:<br />
<br />
- whole dbadmin.js file;<br />
- a server block from nginx configuration file with a full location<br />
description<br />
<br />
For development and testing I'd recommend to use:<br />
- curl command line utility, i.e. something like:<br />
% curl -v --data-binary @test.bin http://127.0.0.1:8080/test?foo=bar\&baz=1<br />
<br />
- enable debugging as described at http://nginx.org/en/docs/debugging_log.html<br />
so you'll be able to see what's going on with a request processing<br />
<br />
--<br />
Sergey<br />
_______________________________________________<br />
nginx mailing list<br />
nginx@nginx.org<br />
http://mailman.nginx.org/mailman/listinfo/nginx</blockquote>
</div>
</body>
</html>