Changeset

2210:78c9b5255b27

Adding some human readable error messages.
author Tobias Markmann <tm@ayena.de>
date Thu, 19 Nov 2009 17:17:52 +0100
parents 2209:adbedc32d41b
children 2211:6094a4e2b6f3
files util/sasl/plain.lua util/sasl/scram.lua
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/util/sasl/plain.lua	Thu Nov 19 17:08:58 2009 +0100
+++ b/util/sasl/plain.lua	Thu Nov 19 17:17:52 2009 +0100
@@ -35,7 +35,7 @@
 	
 	if (not password) or (password == "") or (not authentication) or (authentication == "") then
 		log("debug", "Username or password violates SASLprep.");
-		return "failure", "malformed-request";
+		return "failure", "malformed-request", "Invalid username or password.";
 	end
 
 	local correct, state = false, false;
@@ -55,7 +55,7 @@
 	if correct then
 		return "success";
 	else
-		return "failure", "not-authorized";
+		return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent.";
 	end
 end
 
--- a/util/sasl/scram.lua	Thu Nov 19 17:08:58 2009 +0100
+++ b/util/sasl/scram.lua	Thu Nov 19 17:17:52 2009 +0100
@@ -95,7 +95,7 @@
 		self.state.name = validate_username(self.state.name);
 		if not self.state.name then
 			log("debug", "Username violates either SASLprep or contains forbidden character sequences.")
-			return "failure", "malformed-request";
+			return "failure", "malformed-request", "Invalid username.";
 		end
 		
 		self.state["servernonce"] = generate_uuid();
@@ -113,7 +113,7 @@
 		self.state["nonce"] = client_final_message:match("r=(.+),p=");
 		self.state["channelbinding"] = client_final_message:match("c=(.+),r=");
 		if not self.state.proof or not self.state.nonce or not self.state.channelbinding then
-			return "failure", "malformed-request";
+			return "failure", "malformed-request", "Missing an attribute(p, r or c) in SASL message.";
 		end
 		
 		local password;
@@ -124,7 +124,7 @@
 			password = saslprep(password);
 			if not password then
 				log("debug", "Password violates SASLprep.");
-				return "failure", "not-authorized"
+				return "failure", "not-authorized", "Invalid password."
 			end
 		end