Software /
code /
prosody-modules
Comparison
mod_auth_external/mod_auth_external.lua @ 2827:45380b77303d
mod_auth_external: Split long lines [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 Nov 2017 00:34:47 +0100 |
parent | 1997:199fb0a82c0a |
child | 2828:3ba36b66f297 |
comparison
equal
deleted
inserted
replaced
2826:ed26608920d4 | 2827:45380b77303d |
---|---|
22 local command = module:get_option_string("external_auth_command", ""); | 22 local command = module:get_option_string("external_auth_command", ""); |
23 local read_timeout = module:get_option_number("external_auth_timeout", 5); | 23 local read_timeout = module:get_option_number("external_auth_timeout", 5); |
24 local blocking = module:get_option_boolean("external_auth_blocking", not(have_async and server.event and lpty.getfd)); | 24 local blocking = module:get_option_boolean("external_auth_blocking", not(have_async and server.event and lpty.getfd)); |
25 local auth_processes = module:get_option_number("external_auth_processes", 1); | 25 local auth_processes = module:get_option_number("external_auth_processes", 1); |
26 | 26 |
27 assert(script_type == "ejabberd" or script_type == "generic", "Config error: external_auth_protocol must be 'ejabberd' or 'generic'"); | 27 assert(script_type == "ejabberd" or script_type == "generic", |
28 "Config error: external_auth_protocol must be 'ejabberd' or 'generic'"); | |
28 assert(not host:find(":"), "Invalid hostname"); | 29 assert(not host:find(":"), "Invalid hostname"); |
29 | 30 |
30 | 31 |
31 if not blocking then | 32 if not blocking then |
32 log("debug", "External auth in non-blocking mode, yay!") | 33 log("debug", "External auth in non-blocking mode, yay!") |
106 return nil, "not-authorized"; | 107 return nil, "not-authorized"; |
107 elseif (script_type == "ejabberd" and response == "\0\2\0\1") or | 108 elseif (script_type == "ejabberd" and response == "\0\2\0\1") or |
108 (script_type == "generic" and response:gsub("\r?\n$", "") == "1") then | 109 (script_type == "generic" and response:gsub("\r?\n$", "") == "1") then |
109 return true; | 110 return true; |
110 else | 111 else |
111 log("warn", "Unable to interpret data from auth process, %s", (response:match("^error:") and response) or ("["..#response.." bytes]")); | 112 log("warn", "Unable to interpret data from auth process, %s", |
113 (response:match("^error:") and response) or ("["..#response.." bytes]")); | |
112 return nil, "internal-server-error"; | 114 return nil, "internal-server-error"; |
113 end | 115 end |
114 end | 116 end |
115 | 117 |
116 local host = module.host; | 118 local host = module.host; |