mod_saslauth: Fire event per SASL step
authorMatthew Wild <mwild1@gmail.com>
Tue, 05 Dec 2023 11:39:11 +0000
changeset 13390 33e5edbd6a4a
parent 13389 72d7830505f0
child 13391 e5ddae99faa8
mod_saslauth: Fire event per SASL step This matches the behaviour of the newer mod_sasl2 implementation. It allows plugins to observe (and potentially, with caution, modify) the SASL exchange.
plugins/mod_saslauth.lua
--- a/plugins/mod_saslauth.lua	Sat Dec 02 21:45:38 2023 +0100
+++ b/plugins/mod_saslauth.lua	Tue Dec 05 11:39:11 2023 +0000
@@ -87,9 +87,12 @@
 			return true;
 		end
 	end
-	local status, ret, err_msg = session.sasl_handler:process(text);
+	local sasl_handler = session.sasl_handler;
+	local status, ret, err_msg = sasl_handler:process(text);
 	status, ret, err_msg = handle_status(session, status, ret, err_msg);
-	local s = build_reply(status, ret, err_msg);
+	local event = { session = session, message = ret, error_text = err_msg };
+	module:fire_event("sasl/"..session.base_type.."/"..status, event);
+	local s = build_reply(status, event.message, event.error_text);
 	session.send(s);
 	return true;
 end