util.sasl.*, mod_auth_*, mod_saslauth: Pass SASL handler as first parameter to SASL profile callbacks.
--- a/plugins/mod_auth_anonymous.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/plugins/mod_auth_anonymous.lua Mon Dec 27 19:57:04 2010 +0500
@@ -36,7 +36,7 @@
function provider.get_sasl_handler()
local realm = module:get_option("sasl_realm") or module.host;
local anonymous_authentication_profile = {
- anonymous = function(username, realm)
+ anonymous = function(sasl, username, realm)
return true; -- for normal usage you should always return true here
end
};
--- a/plugins/mod_auth_internal_hashed.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/plugins/mod_auth_internal_hashed.lua Mon Dec 27 19:57:04 2010 +0500
@@ -138,7 +138,7 @@
function provider.get_sasl_handler()
local realm = module:get_option("sasl_realm") or module.host;
local testpass_authentication_profile = {
- plain_test = function(username, password, realm)
+ plain_test = function(sasl, username, password, realm)
local prepped_username = nodeprep(username);
if not prepped_username then
log("debug", "NODEprep failed on username: %s", username);
@@ -146,7 +146,7 @@
end
return usermanager.test_password(prepped_username, realm, password), true;
end,
- scram_sha_1 = function(username, realm)
+ scram_sha_1 = function(sasl, username, realm)
local credentials = datamanager.load(username, host, "accounts");
if not credentials then return; end
if credentials.password then
--- a/plugins/mod_auth_internal_plain.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/plugins/mod_auth_internal_plain.lua Mon Dec 27 19:57:04 2010 +0500
@@ -66,7 +66,7 @@
function provider.get_sasl_handler()
local realm = module:get_option("sasl_realm") or module.host;
local getpass_authentication_profile = {
- plain = function(username, realm)
+ plain = function(sasl, username, realm)
local prepped_username = nodeprep(username);
if not prepped_username then
log("debug", "NODEprep failed on username: %s", username);
--- a/plugins/mod_saslauth.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/plugins/mod_saslauth.lua Mon Dec 27 19:57:04 2010 +0500
@@ -34,7 +34,7 @@
local new_sasl = require "util.sasl".new;
local anonymous_authentication_profile = {
- anonymous = function(username, realm)
+ anonymous = function(sasl, username, realm)
return true; -- for normal usage you should always return true here
end
};
--- a/util/sasl/anonymous.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/util/sasl/anonymous.lua Mon Dec 27 19:57:04 2010 +0500
@@ -34,7 +34,7 @@
local username;
repeat
username = generate_uuid();
- until self.profile.anonymous(username, self.realm);
+ until self.profile.anonymous(self, username, self.realm);
self.username = username;
return "success"
end
--- a/util/sasl/digest-md5.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/util/sasl/digest-md5.lua Mon Dec 27 19:57:04 2010 +0500
@@ -181,12 +181,12 @@
self.username = response["username"];
local Y, state;
if self.profile.plain then
- local password, state = self.profile.plain(response["username"], self.realm)
+ local password, state = self.profile.plain(self, response["username"], self.realm)
if state == nil then return "failure", "not-authorized"
elseif state == false then return "failure", "account-disabled" end
Y = md5(response["username"]..":"..response["realm"]..":"..password);
elseif self.profile["digest-md5"] then
- Y, state = self.profile["digest-md5"](response["username"], self.realm, response["realm"], response["charset"])
+ Y, state = self.profile["digest-md5"](self, response["username"], self.realm, response["realm"], response["charset"])
if state == nil then return "failure", "not-authorized"
elseif state == false then return "failure", "account-disabled" end
elseif self.profile["digest-md5-test"] then
--- a/util/sasl/plain.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/util/sasl/plain.lua Mon Dec 27 19:57:04 2010 +0500
@@ -57,10 +57,10 @@
local correct, state = false, false;
if self.profile.plain then
local correct_password;
- correct_password, state = self.profile.plain(authentication, self.realm);
+ correct_password, state = self.profile.plain(self, authentication, self.realm);
correct = (correct_password == password);
elseif self.profile.plain_test then
- correct, state = self.profile.plain_test(authentication, password, self.realm);
+ correct, state = self.profile.plain_test(self, authentication, password, self.realm);
end
self.username = authentication
--- a/util/sasl/scram.lua Mon Dec 27 19:43:57 2010 +0500
+++ b/util/sasl/scram.lua Mon Dec 27 19:57:04 2010 +0500
@@ -143,7 +143,7 @@
-- retreive credentials
if self.profile.plain then
- local password, state = self.profile.plain(self.state.name, self.realm)
+ local password, state = self.profile.plain(self, self.state.name, self.realm)
if state == nil then return "failure", "not-authorized"
elseif state == false then return "failure", "account-disabled" end
@@ -163,7 +163,7 @@
return "failure", "temporary-auth-failure";
end
elseif self.profile["scram_"..hashprep(hash_name)] then
- local stored_key, server_key, iteration_count, salt, state = self.profile["scram_"..hashprep(hash_name)](self.state.name, self.realm);
+ local stored_key, server_key, iteration_count, salt, state = self.profile["scram_"..hashprep(hash_name)](self, self.state.name, self.realm);
if state == nil then return "failure", "not-authorized"
elseif state == false then return "failure", "account-disabled" end