# HG changeset patch # User Kim Alvefur # Date 1509474714 -3600 # Node ID 39156d6f7268f2b0a063d81fe83eb746bad2f183 # Parent 9a3e51f348fe2ad546484335d6a7c50abc0b8bbe mod_auth_http_async: Allow LuaSocket to pollute the global scope (fixes #1033) diff -r 9a3e51f348fe -r 39156d6f7268 mod_auth_http_async/mod_auth_http_async.lua --- a/mod_auth_http_async/mod_auth_http_async.lua Sat Oct 28 17:17:59 2017 +0200 +++ b/mod_auth_http_async/mod_auth_http_async.lua Tue Oct 31 19:31:54 2017 +0100 @@ -26,9 +26,17 @@ if rawget(_G, "base_parsed") == nil then rawset(_G, "base_parsed", false) end +if not have_async then -- FINE! Set your globals then + prosody.unlock_globals() + require "ltn12" + require "socket" + require "socket.http" + require "ssl.https" + prosody.lock_globals() +end local function async_http_auth(url, username, password) -module:log("debug", "async_http_auth()"); + module:log("debug", "async_http_auth()"); local http = require "net.http"; local wait, done = async.waiter(); local content, code, request, response; @@ -51,7 +59,8 @@ end local function sync_http_auth(url,username, password) -module:log("debug", "sync_http_auth()"); + module:log("debug", "sync_http_auth()"); + require "ltn12"; local http = require "socket.http"; local https = require "ssl.https"; local request; @@ -113,4 +122,4 @@ }); end -module:provides("auth", provider); \ No newline at end of file +module:provides("auth", provider);