diff options
author | Tobias Markmann <tm@ayena.de> | 2008-11-10 16:28:15 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2008-11-10 16:28:15 +0100 |
commit | c4d2deffc64a4d955e52d7e8b2dce3af444872c7 (patch) | |
tree | 8dd7f6632d952b852682ffb6ff6a0ceba8fcc21d /plugins | |
parent | 346b695b798ac36147be7d47f3dfb7a946776358 (diff) | |
download | prosody-c4d2deffc64a4d955e52d7e8b2dce3af444872c7.tar.gz prosody-c4d2deffc64a4d955e52d7e8b2dce3af444872c7.zip |
Forward response stanzas to sasl.lua and some other stuff.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_saslauth.lua | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 24c82a1c..4f4f29d4 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -15,50 +15,55 @@ local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; local new_sasl = require "util.sasl".new; -add_handler("c2s_unauthed", "auth", xmlns_sasl, - function (session, stanza) - if not session.sasl_handler then - session.sasl_handler = new_sasl(stanza.attr.mechanism, - function (username, password) - -- onAuth - require "core.usermanager" - if usermanager_validate_credentials(session.host, username, password) then - return true; - end - return false; - end, - function (username) - -- onSuccess - local success, err = sessionmanager.make_authenticated(session, username); - if not success then - sessionmanager.destroy_session(session); - return; - end - session.sasl_handler = nil; - session:reset_stream(); - end, - function (reason) - -- onFail - log("debug", "SASL failure, reason: %s", reason); - end, - function (stanza) - -- onWrite - log("debug", "SASL writes: %s", tostring(stanza)); - send(session, stanza); - end - ); - session.sasl_handler:feed(stanza); - else - error("Client tried to negotiate SASL again", 0); +add_handler("c2s_unauthed", "auth", xmlns_sasl, function (session, stanza) + if not session.sasl_handler then + session.sasl_handler = new_sasl(stanza.attr.mechanism, + function (username, password) + -- onAuth + require "core.usermanager" + if usermanager_validate_credentials(session.host, username, password) then + return true; + end + return false; + end, + function (username) + -- onSuccess + local success, err = sessionmanager.make_authenticated(session, username); + if not success then + sessionmanager.destroy_session(session); + return; + end + session.sasl_handler = nil; + session:reset_stream(); + end, + function (reason) + -- onFail + log("debug", "SASL failure, reason: %s", reason); + end, + function (stanza) + -- onWrite + log("debug", "SASL writes: %s", tostring(stanza)); + send(session, stanza); end - - end); + ); + session.sasl_handler:feed(stanza); + else + error("Client tried to negotiate SASL again", 0); + end +end); + +add_handler("c2s_unauthed", "response", xmlns_sasl, function (session, stanza) + if session.sasl_handler then + session.sasl_handler:feed(stanza); + end +end); add_event_hook("stream-features", function (session, features) if not session.username then t_insert(features, "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"); t_insert(features, "<mechanism>PLAIN</mechanism>"); + t_insert(features, "<mechanism>DIGEST-MD5</mechanism>"); t_insert(features, "</mechanisms>"); else t_insert(features, "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind>"); |