sasl: Expose what mechanisms were offered on authentication-failure

Fri, 17 Mar 2023 09:24:36 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 17 Mar 2023 09:24:36 +0000
changeset 467
8e6a7a5e70b3
parent 466
1eaec52ff71a
child 468
fae5ae0ddb84

sasl: Expose what mechanisms were offered on authentication-failure

plugins/sasl.lua file | annotate | diff | comparison | revisions
--- 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

mercurial