comparison mod_log_auth/mod_log_auth.lua @ 1427:322a076f53e8

mod_log_auth: Add ability to log IPs of successful authentications too
author Matthew Wild <mwild1@gmail.com>
date Sat, 31 May 2014 13:38:35 +0100
parents 608d9019b0de
children 9d43095d915f
comparison
equal deleted inserted replaced
1426:249c5447fed1 1427:322a076f53e8
1 local mode = module:get_option_string("log_auth_ips", "failure");
2 assert(({ all = true, failure = true, success = true })[mode], "Unknown log mode: "..tostring(mode).." - valid modes are 'all', 'failure', 'success'");
1 3
2 module:hook("authentication-failure", function (event) 4 if mode == "failure" or mode == "all" then
3 module:log("info", "Failed authentication attempt (%s) from IP: %s", event.condition or "unknown-condition", event.session.ip or "?"); 5 module:hook("authentication-failure", function (event)
4 end); 6 module:log("info", "Failed authentication attempt (%s) from IP: %s", event.condition or "unknown-condition", event.session.ip or "?");
7 end);
8 end
9
10 if mode == "success" or mode == "all" then
11 module:hook("authentication-success", function (event)
12 local session = event.session;
13 module:log("info", "Successful authentication as %s from IP: %s", session.username, session.ip or "?");
14 end);
15 end