mod_audit_auth/mod_audit_auth.lua
changeset 5752 dfbced5e54b9
parent 5716 b357ff3d0c8a
child 5753 238c4ac8b735
equal deleted inserted replaced
5751:111e970213a0 5752:dfbced5e54b9
     1 local jid = require"util.jid";
     1 local jid = require"util.jid";
     2 
     2 
     3 module:depends("audit");
     3 module:depends("audit");
     4 -- luacheck: read globals module.audit
     4 -- luacheck: read globals module.audit
       
     5 
       
     6 local only_passwords = module:get_option_boolean("audit_auth_passwords_only", true);
     5 
     7 
     6 module:hook("authentication-failure", function(event)
     8 module:hook("authentication-failure", function(event)
     7 	local session = event.session;
     9 	local session = event.session;
     8 	module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-failure", {
    10 	module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-failure", {
     9 		session = session,
    11 		session = session,
    10 	});
    12 	});
    11 end)
    13 end)
    12 
    14 
    13 module:hook("authentication-success", function(event)
    15 module:hook("authentication-success", function(event)
    14 	local session = event.session;
    16 	local session = event.session;
       
    17 	if only_passwords and session.sasl_handler.fast then
       
    18 		return;
       
    19 	end
    15 	module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-success", {
    20 	module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-success", {
    16 		session = session,
    21 		session = session,
    17 	});
    22 	});
    18 end)
    23 end)