Software /
code /
prosody-modules
Comparison
mod_log_auth/mod_log_auth.lua @ 2084:9d43095d915f
mod_log_auth: Include username, if known
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 15 Mar 2016 16:46:44 +0100 |
parent | 1427:322a076f53e8 |
child | 2695:8b21f13b08c5 |
comparison
equal
deleted
inserted
replaced
2083:fed0a71a5e68 | 2084:9d43095d915f |
---|---|
1 local mode = module:get_option_string("log_auth_ips", "failure"); | 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'"); | 2 assert(({ all = true, failure = true, success = true })[mode], "Unknown log mode: "..tostring(mode).." - valid modes are 'all', 'failure', 'success'"); |
3 | 3 |
4 if mode == "failure" or mode == "all" then | 4 if mode == "failure" or mode == "all" then |
5 module:hook("authentication-failure", function (event) | 5 module:hook("authentication-failure", function (event) |
6 module:log("info", "Failed authentication attempt (%s) from IP: %s", event.condition or "unknown-condition", event.session.ip or "?"); | 6 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 "?"); |
7 end); | 7 end); |
8 end | 8 end |
9 | 9 |
10 if mode == "success" or mode == "all" then | 10 if mode == "success" or mode == "all" then |
11 module:hook("authentication-success", function (event) | 11 module:hook("authentication-success", function (event) |