comparison mod_log_auth/mod_log_auth.lua @ 2699:dae655657a92

mod_log_auth: log into session
author Georg Lukas <georg@op-co.de>
date Wed, 19 Apr 2017 13:45:18 +0200
parents 88205b77e385
children 6d1ec8099315
comparison
equal deleted inserted replaced
2698:88205b77e385 2699:dae655657a92
4 4
5 if mode == "failure" or mode == "all" then 5 if mode == "failure" or mode == "all" then
6 module:hook("authentication-failure", function (event) 6 module:hook("authentication-failure", function (event)
7 local session = event.session; 7 local session = event.session;
8 local username = session.username or session.sasl_handler and session.sasl_handler.username or "?"; 8 local username = session.username or session.sasl_handler and session.sasl_handler.username or "?";
9 module:log("info", "Failed authentication attempt (%s) for user %s from IP: %s", 9 session.log("info", "Failed authentication attempt (%s) for user %s from IP: %s",
10 event.condition or "unknown-condition", username, session.ip or "?"); 10 event.condition or "unknown-condition", username, session.ip or "?");
11 end); 11 end);
12 end 12 end
13 13
14 if mode == "success" or mode == "all" then 14 if mode == "success" or mode == "all" then
15 module:hook("authentication-success", function (event) 15 module:hook("authentication-success", function (event)
16 local session = event.session; 16 local session = event.session;
17 module:log("info", "Successful authentication as %s from IP: %s", session.username, session.ip or "?"); 17 session.log("info", "Successful authentication as %s from IP: %s", session.username, session.ip or "?");
18 end); 18 end);
19 end 19 end