Comparison

plugins/mod_saslauth.lua @ 4939:0545a574667b

mod_saslauth: Pass session to usermanager.get_sasl_handler()
author Matthew Wild <mwild1@gmail.com>
date Wed, 04 Jul 2012 23:44:13 +0100
parent 4754:449a78f91f0e
child 5351:901ed253bbf7
comparison
equal deleted inserted replaced
4938:76a960bff4c7 4939:0545a574667b
206 206
207 if session.sasl_handler and session.sasl_handler.selected then 207 if session.sasl_handler and session.sasl_handler.selected then
208 session.sasl_handler = nil; -- allow starting a new SASL negotiation before completing an old one 208 session.sasl_handler = nil; -- allow starting a new SASL negotiation before completing an old one
209 end 209 end
210 if not session.sasl_handler then 210 if not session.sasl_handler then
211 session.sasl_handler = usermanager_get_sasl_handler(module.host); 211 session.sasl_handler = usermanager_get_sasl_handler(module.host, session);
212 end 212 end
213 local mechanism = stanza.attr.mechanism; 213 local mechanism = stanza.attr.mechanism;
214 if not session.secure and (secure_auth_only or (mechanism == "PLAIN" and not allow_unencrypted_plain_auth)) then 214 if not session.secure and (secure_auth_only or (mechanism == "PLAIN" and not allow_unencrypted_plain_auth)) then
215 session.send(build_reply("failure", "encryption-required")); 215 session.send(build_reply("failure", "encryption-required"));
216 return true; 216 return true;
244 local origin, features = event.origin, event.features; 244 local origin, features = event.origin, event.features;
245 if not origin.username then 245 if not origin.username then
246 if secure_auth_only and not origin.secure then 246 if secure_auth_only and not origin.secure then
247 return; 247 return;
248 end 248 end
249 origin.sasl_handler = usermanager_get_sasl_handler(module.host); 249 origin.sasl_handler = usermanager_get_sasl_handler(module.host, origin);
250 local mechanisms = st.stanza("mechanisms", mechanisms_attr); 250 local mechanisms = st.stanza("mechanisms", mechanisms_attr);
251 for mechanism in pairs(origin.sasl_handler:mechanisms()) do 251 for mechanism in pairs(origin.sasl_handler:mechanisms()) do
252 if mechanism ~= "PLAIN" or origin.secure or allow_unencrypted_plain_auth then 252 if mechanism ~= "PLAIN" or origin.secure or allow_unencrypted_plain_auth then
253 mechanisms:tag("mechanism"):text(mechanism):up(); 253 mechanisms:tag("mechanism"):text(mechanism):up();
254 end 254 end