mod_storage_sql: Reconnect in all cases, and rollback on error.
[prosody.git] / util / sasl / scram.lua
index 7354c8fc0906cc7e0effd4957993339dafab8d96..530ef5a005614837b2edd440b9df120b8cc203a3 100644 (file)
@@ -67,7 +67,7 @@ end
 -- hash algorithm independent Hi(PBKDF2) implementation
 function Hi(hmac, str, salt, i)
        local Ust = hmac(str, salt.."\0\0\0\1");
-       local res = Ust;        
+       local res = Ust;
        for n=1,i-1 do
                local Und = hmac(str, Ust)
                res = binaryXOR(res, Und)
@@ -80,8 +80,8 @@ local function validate_username(username)
        -- check for forbidden char sequences
        for eq in username:gmatch("=(.?.?)") do
                if eq ~= "2D" and eq ~= "3D" then
-                       return false 
-               end 
+                       return false
+               end
        end
        
        -- replace =2D with , and =3D with =
@@ -143,7 +143,7 @@ local function scram_gen(hash_name, H_f, HMAC_f)
                        
                        -- 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 @@ local function scram_gen(hash_name, H_f, HMAC_f)
                                        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