diff options
author | Waqas Hussain <waqas20@gmail.com> | 2008-11-16 01:54:14 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2008-11-16 01:54:14 +0500 |
commit | a055e3c41b0b378079678c733ccbf424f36140f6 (patch) | |
tree | 20bf6b7cd0bf740717f6451f5cee0eaf55747676 | |
parent | e9de112af306218381314735676ffd399e2cda51 (diff) | |
download | prosody-a055e3c41b0b378079678c733ccbf424f36140f6.tar.gz prosody-a055e3c41b0b378079678c733ccbf424f36140f6.zip |
Started using realm in password hashing, and added support for error message replies from sasl
-rw-r--r-- | plugins/mod_saslauth.lua | 12 | ||||
-rw-r--r-- | util/sasl.lua | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 2b48ccff..5f7438d2 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -17,12 +17,13 @@ local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; local new_sasl = require "util.sasl".new; -local function build_reply(status, ret) +local function build_reply(status, ret, err_msg) local reply = st.stanza(status, {xmlns = xmlns_sasl}); if status == "challenge" then reply:text(ret or ""); elseif status == "failure" then reply:tag(ret):up(); + if err_msg then reply:tag("text"); end elseif status == "success" then reply:text(ret or ""); else @@ -42,15 +43,14 @@ local function handle_status(session, status) end end -local function password_callback(jid, mechanism) - local node, host = jid_split(jid); +local function password_callback(node, host, mechanism) local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords local func = function(x) return x; end; if password then if mechanism == "PLAIN" then return func, password; elseif mechanism == "DIGEST-MD5" then - return func, require "hashes".md5(node.."::"..password); + return func, require "hashes".md5(node..":"..host..":"..password); end end return func, nil; @@ -66,9 +66,9 @@ function do_sasl(session, stanza) return; end end - local status, ret = session.sasl_handler:feed(text); + local status, ret, err_msg = session.sasl_handler:feed(text); handle_status(session, status); - local s = build_reply(status, ret); + local s = build_reply(status, ret, err_msg); log("debug", "sasl reply: "..tostring(s)); session.send(s); end diff --git a/util/sasl.lua b/util/sasl.lua index 430bfe5c..fe5b2d3c 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -1,7 +1,7 @@ local base64 = require "base64" local md5 = require "md5" -local crypto = require "crypto" +--local crypto = require "crypto" local log = require "util.logger".init("sasl"); local tostring = tostring; local st = require "util.stanza"; |