diff options
author | Tobias Markmann <tm@ayena.de> | 2008-11-15 22:36:22 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2008-11-15 22:36:22 +0100 |
commit | f2bca1da103f2c790fff5825c24381aa1e313153 (patch) | |
tree | 307b9ba67d49dbe9e3a05b88687a5fcd2544e5d2 /plugins/mod_saslauth.lua | |
parent | a06fac33d5d45e318035e2d38c067281ce8eb419 (diff) | |
parent | f2ffc8c3232ab0db6c0b7ba0a385a0f3584959f6 (diff) | |
download | prosody-f2bca1da103f2c790fff5825c24381aa1e313153.tar.gz prosody-f2bca1da103f2c790fff5825c24381aa1e313153.zip |
Providing some human readable error messages and some fixes.
Diffstat (limited to 'plugins/mod_saslauth.lua')
-rw-r--r-- | plugins/mod_saslauth.lua | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 05c581ca..2094867f 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -51,13 +51,19 @@ local function password_callback(node, host, mechanism) if mechanism == "PLAIN" then return func, password; elseif mechanism == "DIGEST-MD5" then - return func, require "hashes".md5(node..":"..host..":"..password); + return func, require "md5".sum(node..":"..host..":"..password); end end return func, nil; end -function do_sasl(session, stanza) +function sasl_handler(session, stanza) + if stanza.name == "auth" then + -- FIXME ignoring duplicates because ejabberd does + session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback); + elseif not session.sasl_handler then + return; -- FIXME ignoring out of order stanzas because ejabberd does + end local text = stanza[1]; if text then text = base64.decode(text); @@ -74,27 +80,9 @@ function do_sasl(session, stanza) session.send(s); end -add_handler("c2s_unauthed", "auth", xmlns_sasl, - function (session, stanza) - if not session.sasl_handler then - session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback); - do_sasl(session, stanza); - else - error("Client tried to negotiate SASL again", 0); - end - end); - -add_handler("c2s_unauthed", "abort", xmlns_sasl, - function(session, stanza) - if not session.sasl_handler then error("Attempt to abort when sasl has not started"); end - do_sasl(session, stanza); - end); - -add_handler("c2s_unauthed", "response", xmlns_sasl, - function(session, stanza) - if not session.sasl_handler then error("Attempt to respond when sasl has not started"); end - do_sasl(session, stanza); - end); +add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler); +add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler); +add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler); add_event_hook("stream-features", function (session, features) |