diff options
author | Kim Alvefur <zash@zash.se> | 2014-11-20 15:01:47 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-11-20 15:01:47 +0100 |
commit | 1875a89b0269a92b965298f3ca9f234630e11721 (patch) | |
tree | 1942217f4c99d9e88151d983acabdd514ac04386 /plugins/mod_saslauth.lua | |
parent | 1717f1f2e18c51a7c3091f4a98f35db0b1de6860 (diff) | |
parent | 6d35997e95d6491c72dcfc4b1ecf782e7542fbe5 (diff) | |
download | prosody-1875a89b0269a92b965298f3ca9f234630e11721.tar.gz prosody-1875a89b0269a92b965298f3ca9f234630e11721.zip |
Merge 0.10->trunk
Diffstat (limited to 'plugins/mod_saslauth.lua')
-rw-r--r-- | plugins/mod_saslauth.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index e42adbe1..7e9b0720 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -214,6 +214,10 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:abort", function(event) return true; end); +local function tls_unique(self) + return self.userdata["tls-unique"]:getpeerfinished(); +end + local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; @@ -223,19 +227,23 @@ module:hook("stream-features", function(event) if secure_auth_only and not origin.secure then return; end - origin.sasl_handler = usermanager_get_sasl_handler(module.host, origin); + local sasl_handler = usermanager_get_sasl_handler(module.host, origin) + origin.sasl_handler = sasl_handler; if origin.encrypted then -- check wether LuaSec has the nifty binding to the function needed for tls-unique -- FIXME: would be nice to have this check only once and not for every socket - if origin.conn:socket().getpeerfinished and origin.sasl_handler.add_cb_handler then - origin.sasl_handler:add_cb_handler("tls-unique", function(self) - return self.userdata:getpeerfinished(); - end); - origin.sasl_handler["userdata"] = origin.conn:socket(); + if sasl_handler.add_cb_handler then + local socket = origin.conn:socket(); + if socket.getpeerfinished then + sasl_handler:add_cb_handler("tls-unique", tls_unique); + end + sasl_handler["userdata"] = { + ["tls-unique"] = socket; + }; end end local mechanisms = st.stanza("mechanisms", mechanisms_attr); - for mechanism in pairs(origin.sasl_handler:mechanisms()) do + for mechanism in pairs(sasl_handler:mechanisms()) do if (not disabled_mechanisms:contains(mechanism)) and (origin.secure or not insecure_mechanisms:contains(mechanism)) then mechanisms:tag("mechanism"):text(mechanism):up(); end |