view mod_log_auth/mod_log_auth.lua @ 2609:6ab46ff685d0

mod_cloud_notify: Respect Daniel's business rules and remove endpoints on error Daniel's business rules can be found here: https://mail.jabber.org/pipermail/standards/2016-February/030925.html All implementation changes are documented in depth in the file business_rules.markdown
author tmolitor <thilo@eightysoft.de>
date Sat, 11 Mar 2017 01:42:45 +0100
parents 9d43095d915f
children 8b21f13b08c5
line wrap: on
line source

local mode = module:get_option_string("log_auth_ips", "failure");
assert(({ all = true, failure = true, success = true })[mode], "Unknown log mode: "..tostring(mode).." - valid modes are 'all', 'failure', 'success'");

if mode == "failure" or mode == "all" then
	module:hook("authentication-failure", function (event)
		module:log("info", "Failed authentication attempt (%s) for user %s from IP: %s", event.condition or "unknown-condition", event.session.username or "?", event.session.ip or "?");
	end);
end

if mode == "success" or mode == "all" then
	module:hook("authentication-success", function (event)
		local session = event.session;
		module:log("info", "Successful authentication as %s from IP: %s", session.username, session.ip or "?");
	end);
end