Diff

plugins/sasl.lua @ 467:8e6a7a5e70b3

sasl: Expose what mechanisms were offered on authentication-failure
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Mar 2023 09:24:36 +0000
parent 456:6a65142052c8
child 490:6b2f31da9610
line wrap: on
line diff
--- a/plugins/sasl.lua	Fri Mar 17 09:23:56 2023 +0000
+++ b/plugins/sasl.lua	Fri Mar 17 09:24:36 2023 +0000
@@ -11,10 +11,12 @@
 
 		local mechanisms = {};
 		local preference = {};
+		local offered = {};
 
 		for mech in sasl_mechanisms:childtags("mechanism") do
 			mech = mech:get_text();
 			stream:debug("Server offers %s", mech);
+			offered[mech] = true;
 			if not mechanisms[mech] then
 				local name = mech:match("[^-]+");
 				local ok, impl = pcall(require, "util.sasl."..name:lower());
@@ -32,7 +34,7 @@
 			table.insert(supported, mech);
 		end
 		if not supported[1] then
-			stream:event("authentication-failure", { condition = "no-supported-sasl-mechanisms", mechanisms = mechanisms });
+			stream:event("authentication-failure", { condition = "no-supported-sasl-mechanisms", mechanisms = offered });
 			stream:close();
 			return;
 		end