certs: Add a default OpenSSL configuration file, and a Makefile.
[prosody.git] / plugins / mod_auth_internal_hashed.lua
index 39a263dcbccba099f9c8e6c84e589dca3bf2fc3c..300bebf80f02e79562d71dd971ef8e675885e01a 100644 (file)
@@ -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,13 +144,15 @@ 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
@@ -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);