Auth Basic can be done directly against postgres, plus a few more modules (headers-more and eval was how I did it, IIRC). Could probably do it with just openresty too.
After authentication, you have the credentials needed check authorization, it'd probably just involve a few changes to the SQL in the article.