Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've written an authorization server for CloudFront using Python/Flask and have wondered whether just writing the same functionality via Lua could be a better/faster replacement. I'm just not clear on how to use Lua to make the calls to our API. This is a good pointer in the right direction though.


Nginx exposes multiple phase to process an incoming HTTP Request. Mainly rewrite, access, content, header_filter, and log

You can embed Lua at the access phase, and query your API from there. Some of the Lua libraries of the OpenResty package [1] might help you do that.

And here [2] you can find an example of OAuth support.

[1] http://openresty.org/#Components [2] http://seatgeek.com/blog/dev/oauth-support-for-nginx-with-lu...


Here is some example auth code for Amazon services in Lua for Nginx I wrote ages ago, which might help get an idea of what the code might look like https://gist.github.com/948423

It is very fast doing that type of stuff in Lua, and it all gets done in the same request context.

There is some new functionality in openresty since that example, so there are probably other choices of ways to implement it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: