README.md

auth-request

auth-request allows you to add access control to your HTTP services based
on a subrequest to a configured haproxy backend. The workings of this Lua
script are loosely based on the ngx_http_auth_request_module module
for nginx.

The Details

The Lua script will make a HTTP request to the first server in the given
backend that is not marked as DOWN. This allows for basic health checking
of the auth-request backend. If you need more complex processing of the
request forward the auth-request to a separate haproxy frontend that
performs the required modifications to the request and response.

The requested URL is the one given in the second parameter.

Any request headers will be forwarded as-is to the auth-request backend.

The Lua script will define the txn.auth_response_successful variable as
true iff the subrequest returns an HTTP status code of 2xx. The status code
of the subrequest will be returned in txn.auth_response_code. If the
subrequest does not return a valid HTTP response the status code is set
to 500 Internal Server Error.

Known limitations

The Lua script only supports basic health checking, without redispatching
or load balancing of any kind.

The response headers of the subrequest are not exposed outside the script.