comparison mod_auth_external/mod_auth_external.lua @ 1160:05685fd07395

mod_auth_external: Re-organise initialization a bit (superficial)
author Matthew Wild <mwild1@gmail.com>
date Wed, 14 Aug 2013 02:27:04 +0100
parents c56a1d449cad
children b9e4d935867c
comparison
equal deleted inserted replaced
1159:c56a1d449cad 1160:05685fd07395
8 -- This project is MIT/X11 licensed. Please see the 8 -- This project is MIT/X11 licensed. Please see the
9 -- COPYING file in the source package for more information. 9 -- COPYING file in the source package for more information.
10 -- 10 --
11 11
12 local lpty = assert(require "lpty", "mod_auth_external requires lpty: https://code.google.com/p/prosody-modules/wiki/mod_auth_external#Installation"); 12 local lpty = assert(require "lpty", "mod_auth_external requires lpty: https://code.google.com/p/prosody-modules/wiki/mod_auth_external#Installation");
13 local usermanager = require "core.usermanager";
14 local new_sasl = require "util.sasl".new;
15 local server = require "net.server";
16 local have_async, async = pcall(require, "util.async");
13 17
14 local log = module._log; 18 local log = module._log;
15 local host = module.host; 19 local host = module.host;
20
16 local script_type = module:get_option_string("external_auth_protocol", "generic"); 21 local script_type = module:get_option_string("external_auth_protocol", "generic");
17 assert(script_type == "ejabberd" or script_type == "generic", "Config error: external_auth_protocol must be 'ejabberd' or 'generic'"); 22 assert(script_type == "ejabberd" or script_type == "generic", "Config error: external_auth_protocol must be 'ejabberd' or 'generic'");
18 local command = module:get_option_string("external_auth_command", ""); 23 local command = module:get_option_string("external_auth_command", "");
19 local read_timeout = module:get_option_number("external_auth_timeout", 5); 24 local read_timeout = module:get_option_number("external_auth_timeout", 5);
20 assert(not host:find(":"), "Invalid hostname"); 25 assert(not host:find(":"), "Invalid hostname");
21 local usermanager = require "core.usermanager";
22 local new_sasl = require "util.sasl".new;
23 local server = require "net.server";
24 local have_async, async = pcall(require, "util.async");
25 26
26 local blocking = module:get_option_boolean("external_auth_blocking", not(have_async and server.event and lpty.getfd)); 27 local blocking = module:get_option_boolean("external_auth_blocking", not(have_async and server.event and lpty.getfd));
27 28
28 if not blocking then 29 if not blocking then
29 log("debug", "External auth in non-blocking mode, yay!") 30 log("debug", "External auth in non-blocking mode, yay!")