Changeset

3238:362b94fa5a30

mod_saslauth: Return proper error on invalid usernames.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 11 Jun 2010 21:01:17 +0500
parents 3237:721a83a3beb9
children 3239:5ea90ee96022
files plugins/mod_saslauth.lua
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Fri Jun 11 20:35:10 2010 +0500
+++ b/plugins/mod_saslauth.lua	Fri Jun 11 21:01:17 2010 +0500
@@ -109,17 +109,17 @@
 		session.sasl_handler = session.sasl_handler:clean_clone();
 	elseif status == "success" then
 		local username = nodeprep(session.sasl_handler.username);
-		if not username then -- TODO move this to sessionmanager
-			module:log("warn", "SASL succeeded but we didn't get a username!");
-			session.sasl_handler = nil;
-			session:reset_stream();
-			return status, ret, err_msg;
-		end
 
 		if not(require_provisioning) or usermanager_user_exists(username, session.host) then
-			sm_make_authenticated(session, session.sasl_handler.username);
-			session.sasl_handler = nil;
-			session:reset_stream();
+			local aret, err = sm_make_authenticated(session, session.sasl_handler.username);
+			if aret then
+				session.sasl_handler = nil;
+				session:reset_stream();
+			else
+				module:log("warn", "SASL succeeded but username was invalid");
+				session.sasl_handler = session.sasl_handler:clean_clone();
+				return "failure", "not-authorized", "User authenticated successfully, but username was invalid";
+			end
 		else
 			module:log("warn", "SASL succeeded but we don't have an account provisioned for %s", username);
 			session.sasl_handler = session.sasl_handler:clean_clone();