diff options
author | Tobias Markmann <tm@ayena.de> | 2008-11-15 20:28:09 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2008-11-15 20:28:09 +0100 |
commit | 0d8a36b732987a9cf82437acd513280c9faa4b08 (patch) | |
tree | 87cbb3360e4fa2ff91cbffded7c518137396f3fd | |
parent | 564d2da8d5616327f54cd4f145098969698ac952 (diff) | |
download | prosody-0d8a36b732987a9cf82437acd513280c9faa4b08.tar.gz prosody-0d8a36b732987a9cf82437acd513280c9faa4b08.zip |
Set username in a SASL object.
-rw-r--r-- | plugins/mod_saslauth.lua | 5 | ||||
-rw-r--r-- | util/sasl.lua | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index b95d160d..314d2502 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -7,6 +7,7 @@ local jid local usermanager_validate_credentials = require "core.usermanager".validate_credentials; local t_concat, t_insert = table.concat, table.insert; local tostring = tostring; +local jid_split = require "util.jid".split local log = require "util.logger".init("mod_saslauth"); @@ -65,7 +66,9 @@ function do_sasl(session, stanza) end local status, ret = session.sasl_handler:feed(text); handle_status(session, status); - session.send(build_reply(status, ret)); + local s = build_reply(status, ret); + log("debug", "sasl reply: "..tostring(s)); + session.send(s); end add_handler("c2s_unauthed", "auth", xmlns_sasl, diff --git a/util/sasl.lua b/util/sasl.lua index 8750ce98..430bfe5c 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -19,7 +19,9 @@ module "sasl" local function new_plain(realm, password_handler) local object = { mechanism = "PLAIN", realm = realm, password_handler = password_handler} object.feed = function(self, message) - log("debug", "feed: "..message) + --print(message:gsub("%W", function (c) return string.format("\\%d", string.byte(c)) end)); + + if message == "" or message == nil then return "failure", "malformed-request" end local response = message local authorization = s_match(response, "([^&%z]+)") local authentication = s_match(response, "%z([^&%z]+)%z") @@ -31,9 +33,12 @@ local function new_plain(realm, password_handler) if password_encoding == nil then claimed_password = password else claimed_password = password_encoding(password) end + self.username = authentication if claimed_password == correct_password then + log("debug", "success") return "success", nil else + log("debug", "failure") return "failure", "not-authorized" end end |