# HG changeset patch # User Matt Loupe # Date 1503516715 18000 # Node ID 1d139e33c502617449c06daca621357c0e58149a # Parent 9756211fcbe3cfa45e0d93d2af5848764a156b6d mod_auth_http_async: Updated sync_http_auth function to accept username and password and send those as a basic authentication header diff -r 9756211fcbe3 -r 1d139e33c502 mod_auth_http_async/mod_auth_http_async.lua --- a/mod_auth_http_async/mod_auth_http_async.lua Tue Aug 22 20:25:58 2017 +0200 +++ b/mod_auth_http_async/mod_auth_http_async.lua Wed Aug 23 14:31:55 2017 -0500 @@ -28,6 +28,7 @@ end local function async_http_auth(url, username, password) +module:log("debug", "async_http_auth()"); local http = require "net.http"; local wait, done = async.waiter(); local content, code, request, response; @@ -49,7 +50,8 @@ return nil, "Auth failed. Invalid username or password."; end -local function sync_http_auth(url) +local function sync_http_auth(url,username, password) +module:log("debug", "sync_http_auth()"); local http = require "socket.http"; local https = require "ssl.https"; local request; @@ -60,7 +62,7 @@ end local _, code, headers, status = request{ url = url, - headers = { ACCEPT = "application/json, text/plain, */*"; } + headers = { Authorization = "Basic "..base64(username..":"..password); } }; if type(code) == "number" and code >= 200 and code <= 299 then module:log("debug", "HTTP auth provider confirmed valid password"); @@ -77,7 +79,7 @@ if (have_async) then return async_http_auth(url, username, password); else - return sync_http_auth(url); + return sync_http_auth(url, username, password); end end @@ -111,4 +113,4 @@ }); end -module:provides("auth", provider); +module:provides("auth", provider); \ No newline at end of file