Good day guys,
I would like to implement custom auth proxy. I'm new to Lua and openresty but have some experience with nginx.
The auth flow I need to implement is as follows:
- For each incoming request:
- Fetch auth token from a cookie (not header)
- Call our internal HTTP REST service (no auth) to convert token to user id, and then another call to fetch capabilities for the user (JSON response)
- Lookup for a presence of a certain capability - if exists, forward request to upstream, otherwise - fancy 404 message
Additional requirements:
- Cache token->capabilities to speedup processing of the next requests
- Select upstream based on the value of Host header in the request
I've spent some time researching openresty, but I can't find some basic infrastructure/flow documentation that explains the basic principals. Is it missing or am I just using wrong keywords?
Libraries wise, I'm looking at lua-resty-mlcache and it looks like it's all I need auth-wise; and I can do capabilities fetching in it's "callback" layer. What do you think?
Any links / tips / suggestions are highly welcomed.
In return I promise to write a detailed tutorial and publish it back to the community :)
Thanks in advance,
Zaar