Software /
code /
prosody
Comparison
plugins/mod_saslauth.lua @ 6517:e733e98a348a
mod_saslauth: Keep sasl_handler in a local variable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 19 Nov 2014 14:37:45 +0100 |
parent | 6493:4e51b5e81bdd |
child | 6518:c0d221b0c94c |
comparison
equal
deleted
inserted
replaced
6515:c9a72c64c3e2 | 6517:e733e98a348a |
---|---|
221 local origin, features = event.origin, event.features; | 221 local origin, features = event.origin, event.features; |
222 if not origin.username then | 222 if not origin.username then |
223 if secure_auth_only and not origin.secure then | 223 if secure_auth_only and not origin.secure then |
224 return; | 224 return; |
225 end | 225 end |
226 origin.sasl_handler = usermanager_get_sasl_handler(module.host, origin); | 226 local sasl_handler = usermanager_get_sasl_handler(module.host, origin) |
227 origin.sasl_handler = sasl_handler; | |
227 if origin.encrypted then | 228 if origin.encrypted then |
228 -- check wether LuaSec has the nifty binding to the function needed for tls-unique | 229 -- check wether LuaSec has the nifty binding to the function needed for tls-unique |
229 -- FIXME: would be nice to have this check only once and not for every socket | 230 -- FIXME: would be nice to have this check only once and not for every socket |
230 if origin.conn:socket().getpeerfinished and origin.sasl_handler.add_cb_handler then | 231 if origin.conn:socket().getpeerfinished and sasl_handler.add_cb_handler then |
231 origin.sasl_handler:add_cb_handler("tls-unique", function(self) | 232 sasl_handler:add_cb_handler("tls-unique", function(self) |
232 return self.userdata:getpeerfinished(); | 233 return self.userdata:getpeerfinished(); |
233 end); | 234 end); |
234 origin.sasl_handler["userdata"] = origin.conn:socket(); | 235 sasl_handler["userdata"] = origin.conn:socket(); |
235 end | 236 end |
236 end | 237 end |
237 local mechanisms = st.stanza("mechanisms", mechanisms_attr); | 238 local mechanisms = st.stanza("mechanisms", mechanisms_attr); |
238 for mechanism in pairs(origin.sasl_handler:mechanisms()) do | 239 for mechanism in pairs(sasl_handler:mechanisms()) do |
239 if (not disabled_mechanisms:contains(mechanism)) and (origin.secure or not insecure_mechanisms:contains(mechanism)) then | 240 if (not disabled_mechanisms:contains(mechanism)) and (origin.secure or not insecure_mechanisms:contains(mechanism)) then |
240 mechanisms:tag("mechanism"):text(mechanism):up(); | 241 mechanisms:tag("mechanism"):text(mechanism):up(); |
241 end | 242 end |
242 end | 243 end |
243 if mechanisms[1] then | 244 if mechanisms[1] then |