# HG changeset patch # User Kim Alvefur # Date 1492577222 -7200 # Node ID 57192cf193c77538f38f753b343b421317d8aa39 # Parent dcda2ae4569dd87b8c33d8bd3fdbb5ade9571e86 util.sasl.plain,scram: Record username in sasl state earlier diff -r dcda2ae4569d -r 57192cf193c7 util/sasl/plain.lua --- a/util/sasl/plain.lua Wed Apr 19 12:40:03 2017 +0100 +++ b/util/sasl/plain.lua Wed Apr 19 06:47:02 2017 +0200 @@ -63,6 +63,8 @@ end end + self.username = authentication + local correct, state = false, false; if self.profile.plain then local correct_password; @@ -72,7 +74,6 @@ correct, state = self.profile.plain_test(self, authentication, password, self.realm); end - self.username = authentication if state == false then return "failure", "account-disabled"; elseif state == nil or not correct then diff -r dcda2ae4569d -r 57192cf193c7 util/sasl/scram.lua --- a/util/sasl/scram.lua Wed Apr 19 12:40:03 2017 +0100 +++ b/util/sasl/scram.lua Wed Apr 19 06:47:02 2017 +0200 @@ -146,6 +146,7 @@ log("debug", "Username violates either SASLprep or contains forbidden character sequences.") return "failure", "malformed-request", "Invalid username."; end + self.username = username; -- retreive credentials local stored_key, server_key, salt, iteration_count; @@ -225,7 +226,6 @@ if StoredKey == H_f(ClientKey) then local server_final_message = "v="..base64.encode(ServerSignature); - self["username"] = state.username; return "success", server_final_message; else return "failure", "not-authorized", "The response provided by the client doesn't match the one we calculated.";