X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_auth_internal_hashed.lua;h=300bebf80f02e79562d71dd971ef8e675885e01a;hb=ff53626e693ddb540f718f4ff7d7e9d63a3eca08;hp=da406e0602c308e5ff096df47256bbddfcfa474b;hpb=17cc3e4937b99e82751e0e2737e782b6684fe27d;p=prosody.git diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua index da406e06..300bebf8 100644 --- a/plugins/mod_auth_internal_hashed.lua +++ b/plugins/mod_auth_internal_hashed.lua @@ -22,7 +22,7 @@ local new_sasl = require "util.sasl".new; local nodeprep = require "util.encodings".stringprep.nodeprep; local hosts = hosts; --- TODO: remove these two lines in near future +-- COMPAT w/old trunk: remove these two lines before 0.8 release local hmac_sha1 = require "util.hmac".sha1; local sha1 = require "util.hashes".sha1; @@ -76,7 +76,7 @@ function new_hashpass_provider(host) end -- convert hexpass to stored_key and server_key - -- TODO: remove this in near future + -- COMPAT w/old trunk: remove before 0.8 release if credentials.hashpass then local salted_password = from_hex(credentials.hashpass); credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key"), true); @@ -121,14 +121,13 @@ function new_hashpass_provider(host) log("debug", "account not found for username '%s' at host '%s'", username, module.host); return nil, "Auth failed. Invalid username"; end - --[[if (account.hashpass == nil or string.len(account.hashpass) == 0) and (account.password == nil or string.len(account.password) == 0) then - log("debug", "account password not set or zero-length for username '%s' at host '%s'", username, module.host); - return nil, "Auth failed. Password invalid."; - end]] return true; end function provider.create_user(username, password) + if password == nil then + return datamanager.store(username, host, "accounts", {}); + end local salt = generate_uuid(); local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, salt, iteration_count); local stored_key_hex = to_hex(stored_key); @@ -145,17 +144,19 @@ function new_hashpass_provider(host) log("debug", "NODEprep failed on username: %s", username); return "", nil; end - return usermanager.test_password(prepped_username, password, realm), true; + return usermanager.test_password(prepped_username, realm, password), true; end, scram_sha_1 = function(username, realm) - local credentials = datamanager.load(username, host, "accounts") or {}; + local credentials = datamanager.load(username, host, "accounts"); + if not credentials then return; end if credentials.password then usermanager.set_password(username, credentials.password, host); - credentials = datamanager.load(username, host, "accounts") or {}; + credentials = datamanager.load(username, host, "accounts"); + if not credentials then return; end end -- convert hexpass to stored_key and server_key - -- TODO: remove this in near future + -- COMPAT w/old trunk: remove before 0.8 release if credentials.hashpass then local salted_password = from_hex(credentials.hashpass); credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key"), true); @@ -163,7 +164,7 @@ function new_hashpass_provider(host) credentials.hashpass = nil datamanager.store(username, host, "accounts", credentials); end - + local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; stored_key = stored_key and from_hex(stored_key); server_key = server_key and from_hex(server_key);