comparison mod_muc_log/mod_muc_log.lua @ 80:bed9a6b40fae

mod_proxy65: basic white list - access control list
author Thilo Cestonaro <thilo@cestona.ro>
date Sun, 01 Nov 2009 16:42:04 +0100
parents 0dfd65bfedb0
children 9ceeab822e40
comparison
equal deleted inserted replaced
79:34f5818c90e9 80:bed9a6b40fae
11 local serialize = require "util.serialization".serialize; 11 local serialize = require "util.serialization".serialize;
12 local datamanager = require "util.datamanager"; 12 local datamanager = require "util.datamanager";
13 local data_load, data_store, data_getpath = datamanager.load, datamanager.store, datamanager.getpath; 13 local data_load, data_store, data_getpath = datamanager.load, datamanager.store, datamanager.getpath;
14 local datastore = "muc_log"; 14 local datastore = "muc_log";
15 local config = {}; 15 local config = {};
16 local verifyAuthRequest = module:require "verifyhttpauth".verifyHttpAuthRequest;
17
16 18
17 19
18 --[[ LuaFileSystem 20 --[[ LuaFileSystem
19 * URL: http://www.keplerproject.org/luafilesystem/index.html 21 * URL: http://www.keplerproject.org/luafilesystem/index.html
20 * Install: luarocks install luafilesystem 22 * Install: luarocks install luafilesystem
419 return tmp; 421 return tmp;
420 else 422 else
421 return generateDayListSiteContentByRoom(bareRoomJid); -- fallback 423 return generateDayListSiteContentByRoom(bareRoomJid); -- fallback
422 end 424 end
423 end 425 end
424 426 local requests = {};
425 function handle_request(method, body, request) 427 function handle_request(method, body, request)
426 local query = splitQuery(request.url.query); 428 local query = splitQuery(request.url.query);
427 local node, host = grepRoomJid(request.url.path); 429 local node, host = grepRoomJid(request.url.path);
428 430
429 if node ~= nil and host ~= nil then 431 if node ~= nil and host ~= nil then
435 else 437 else
436 local subject = "" 438 local subject = ""
437 if room._data ~= nil and room._data.subject ~= nil then 439 if room._data ~= nil and room._data.subject ~= nil then
438 subject = room._data.subject; 440 subject = room._data.subject;
439 end 441 end
440 return createDoc(parseDay(bare, subject, query)); 442 local doc = createDoc(parseDay(bare, subject, query));
443 local id = "thisIsTheId";
444 requests[id] = request;
445 requests[id].doc = doc;
446
447 verifyAuthRequest(request.url.path .. "?" .. request.url.query, "thilo@cestona.ro", id, function (id, confirmed)
448 if confirmed and requests[id] then
449 requests[id].send(requests[id].doc);
450 end
451 end)
452 return true;
441 end 453 end
442 else 454 else
443 return createDoc(generateRoomListSiteContent()); 455 return createDoc(generateRoomListSiteContent());
444 end 456 end
445 else 457 else
446 return createDoc(generateRoomListSiteContent()); 458 return createDoc(generateRoomListSiteContent());
447 end 459 end
448 return; 460 return;
449 end 461 end
450 462
451 config = config_get(module:get_host(), "core", "muc_log"); 463 config = config_get(module:get_host(), "core", "muc_log") or {};
452 464
453 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = "muc_log" }); 465 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = "muc_log" });
454 466
455 module:hook("message/bare", logIfNeeded, 500); 467 module:hook("message/bare", logIfNeeded, 500);
456 module:hook("pre-message/bare", logIfNeeded, 500); 468 module:hook("pre-message/bare", logIfNeeded, 500);