plugins/mod_saslauth.lua

changeset 2877
1edeb8fe7d14
parent 2784
e165414a454c
parent 2860
ad534f89c758
child 2923
b7049746bd29
equal deleted inserted replaced
2813:46dfcc33ea9e 2877:1edeb8fe7d14
36 local new_sasl = require "util.sasl".new; 36 local new_sasl = require "util.sasl".new;
37 37
38 local function build_reply(status, ret, err_msg) 38 local function build_reply(status, ret, err_msg)
39 local reply = st.stanza(status, {xmlns = xmlns_sasl}); 39 local reply = st.stanza(status, {xmlns = xmlns_sasl});
40 if status == "challenge" then 40 if status == "challenge" then
41 log("debug", "%s", ret or ""); 41 --log("debug", "CHALLENGE: %s", ret or "");
42 reply:text(base64.encode(ret or "")); 42 reply:text(base64.encode(ret or ""));
43 elseif status == "failure" then 43 elseif status == "failure" then
44 reply:tag(ret):up(); 44 reply:tag(ret):up();
45 if err_msg then reply:tag("text"):text(err_msg); end 45 if err_msg then reply:tag("text"):text(err_msg); end
46 elseif status == "success" then 46 elseif status == "success" then
47 log("debug", "%s", ret or ""); 47 --log("debug", "SUCCESS: %s", ret or "");
48 reply:text(base64.encode(ret or "")); 48 reply:text(base64.encode(ret or ""));
49 else 49 else
50 module:log("error", "Unknown sasl status: %s", status); 50 module:log("error", "Unknown sasl status: %s", status);
51 end 51 end
52 return reply; 52 return reply;
122 return; -- FIXME ignoring out of order stanzas because ejabberd does 122 return; -- FIXME ignoring out of order stanzas because ejabberd does
123 end 123 end
124 local text = stanza[1]; 124 local text = stanza[1];
125 if text then 125 if text then
126 text = base64.decode(text); 126 text = base64.decode(text);
127 log("debug", "%s", text); 127 --log("debug", "AUTH: %s", text:gsub("[%z\001-\008\011\012\014-\031]", " "));
128 if not text then 128 if not text then
129 session.sasl_handler = nil; 129 session.sasl_handler = nil;
130 session.send(build_reply("failure", "incorrect-encoding")); 130 session.send(build_reply("failure", "incorrect-encoding"));
131 return; 131 return;
132 end 132 end

mercurial