mod_auth_internal_hashed: Added SCRAM-SHA-1 support for SASL.

Mon, 07 Jun 2010 03:07:58 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Mon, 07 Jun 2010 03:07:58 +0500
changeset 3193
d686abb6b069
parent 3192
c690e3c5105c
child 3194
c4069680a01c

mod_auth_internal_hashed: Added SCRAM-SHA-1 support for SASL.

plugins/mod_auth_internal_hashed.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_auth_internal_hashed.lua	Mon Jun 07 02:40:14 2010 +0500
+++ b/plugins/mod_auth_internal_hashed.lua	Mon Jun 07 03:07:58 2010 +0500
@@ -117,6 +117,16 @@
 					return "", nil;
 				end
 				return usermanager.test_password(prepped_username, password, realm), true;
+			end,
+			scram_sha_1 = function(username, realm)
+				local credentials = datamanager.load(username, host, "accounts") or {};
+				if credentials.password then
+					usermanager.set_password(username, credentials.password);
+					credentials = datamanager.load(username, host, "accounts") or {};
+				end
+				local salted_password, iteration_count, salt = credentials.hashpass, credentials.iteration_count, credentials.salt;
+				salted_password = salted_password and salted_password:gsub("..", function(x) return string.char(tonumber(x, 16)); end);
+				return salted_password, iteration_count, salt, true;
 			end
 		};
 		return new_sasl(realm, testpass_authentication_profile);

mercurial