aboutsummaryrefslogtreecommitdiffstats
path: root/util/sasl/plain.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-05 11:29:10 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-05 11:29:10 +0100
commita17cc3b6791eaf110ded69edbc07e41e881e036d (patch)
treeae4b02ccb9e9117eafb78c2d8c74951f6e528972 /util/sasl/plain.lua
parentcca05af3d369ba4e53cd76f7e33196c5ee8415b4 (diff)
parentb05ccd7b3affed026faf4b492d91af972f5ae8ac (diff)
downloadprosody-a17cc3b6791eaf110ded69edbc07e41e881e036d.tar.gz
prosody-a17cc3b6791eaf110ded69edbc07e41e881e036d.zip
Merge Tobias's fancy SASL branch->trunk
Diffstat (limited to 'util/sasl/plain.lua')
-rw-r--r--util/sasl/plain.lua28
1 files changed, 26 insertions, 2 deletions
diff --git a/util/sasl/plain.lua b/util/sasl/plain.lua
index ae5c777a..2abbc53a 100644
--- a/util/sasl/plain.lua
+++ b/util/sasl/plain.lua
@@ -1,5 +1,5 @@
-- sasl.lua v0.4
--- Copyright (C) 2008-2009 Tobias Markmann
+-- Copyright (C) 2008-2010 Tobias Markmann
--
-- All rights reserved.
--
@@ -19,6 +19,26 @@ module "plain"
-- ================================
-- SASL PLAIN according to RFC 4616
+
+--[[
+Supported Authentication Backends
+
+plain:
+ function(username, realm)
+ return password, state;
+ end
+
+plain-test:
+ function(username, realm, password)
+ return true or false, state;
+ end
+
+plain-hashed:
+ function(username, realm)
+ return hashed_password, hash_function, state;
+ end
+]]
+
local function plain(self, message)
if not message then
return "failure", "malformed-request";
@@ -46,6 +66,10 @@ local function plain(self, message)
if correct_password == password then correct = true; else correct = false; end
elseif self.profile.plain_test then
correct, state = self.profile.plain_test(authentication, self.realm, password);
+ elseif self.profile.plain_hashed then
+ local hashed_password, hash_f;
+ hashed_password, hash_f, state = self.profile.plain_hashed(authentication, self.realm);
+ if hashed_password == hash_f(password) then correct = true; else correct = false; end
end
self.username = authentication
@@ -61,7 +85,7 @@ local function plain(self, message)
end
function init(registerMechanism)
- registerMechanism("PLAIN", {"plain", "plain_test"}, plain);
+ registerMechanism("PLAIN", {"plain", "plain_test", "plain_hashed"}, plain);
end
return _M;