Comparison

plugins/mod_saslauth.lua @ 2634:e486aca8c5d1

mod_saslauth: Don't print raw SASL data to avoid logging passwords unnecessarily
author Matthew Wild <mwild1@gmail.com>
date Sat, 13 Feb 2010 19:35:12 +0000
parent 2612:475552b04151
child 2642:333d7e2033b2
comparison
equal deleted inserted replaced
2633:96db2eed2af9 2634:e486aca8c5d1
67 }; 67 };
68 68
69 local function build_reply(status, ret, err_msg) 69 local function build_reply(status, ret, err_msg)
70 local reply = st.stanza(status, {xmlns = xmlns_sasl}); 70 local reply = st.stanza(status, {xmlns = xmlns_sasl});
71 if status == "challenge" then 71 if status == "challenge" then
72 log("debug", "%s", ret or ""); 72 --log("debug", "CHALLENGE: %s", ret or "");
73 reply:text(base64.encode(ret or "")); 73 reply:text(base64.encode(ret or ""));
74 elseif status == "failure" then 74 elseif status == "failure" then
75 reply:tag(ret):up(); 75 reply:tag(ret):up();
76 if err_msg then reply:tag("text"):text(err_msg); end 76 if err_msg then reply:tag("text"):text(err_msg); end
77 elseif status == "success" then 77 elseif status == "success" then
78 log("debug", "%s", ret or ""); 78 --log("debug", "SUCCESS: %s", ret or "");
79 reply:text(base64.encode(ret or "")); 79 reply:text(base64.encode(ret or ""));
80 else 80 else
81 module:log("error", "Unknown sasl status: %s", status); 81 module:log("error", "Unknown sasl status: %s", status);
82 end 82 end
83 return reply; 83 return reply;
121 return; -- FIXME ignoring out of order stanzas because ejabberd does 121 return; -- FIXME ignoring out of order stanzas because ejabberd does
122 end 122 end
123 local text = stanza[1]; 123 local text = stanza[1];
124 if text then 124 if text then
125 text = base64.decode(text); 125 text = base64.decode(text);
126 log("debug", "%s", text:gsub("[%z\001-\008\011\012\014-\031]", " ")); 126 --log("debug", "AUTH: %s", text:gsub("[%z\001-\008\011\012\014-\031]", " "));
127 if not text then 127 if not text then
128 session.sasl_handler = nil; 128 session.sasl_handler = nil;
129 session.send(build_reply("failure", "incorrect-encoding")); 129 session.send(build_reply("failure", "incorrect-encoding"));
130 return; 130 return;
131 end 131 end