Mercurial > prosody-modules
comparison mod_audit_auth/mod_audit_auth.lua @ 5749:238c4ac8b735
mod_audit_auth: Add audit record when a client connects that has not been seen before
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 01 Dec 2023 11:59:02 +0000 |
| parents | dfbced5e54b9 |
| children | f199bff16f1f |
comparison
equal
deleted
inserted
replaced
| 5748:dfbced5e54b9 | 5749:238c4ac8b735 |
|---|---|
| 1 local jid = require"util.jid"; | 1 local jid = require"util.jid"; |
| 2 local st = require "util.stanza"; | |
| 2 | 3 |
| 3 module:depends("audit"); | 4 module:depends("audit"); |
| 4 -- luacheck: read globals module.audit | 5 -- luacheck: read globals module.audit |
| 5 | 6 |
| 6 local only_passwords = module:get_option_boolean("audit_auth_passwords_only", true); | 7 local only_passwords = module:get_option_boolean("audit_auth_passwords_only", true); |
| 19 end | 20 end |
| 20 module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-success", { | 21 module:audit(jid.join(session.sasl_handler.username, module.host), "authentication-success", { |
| 21 session = session, | 22 session = session, |
| 22 }); | 23 }); |
| 23 end) | 24 end) |
| 25 | |
| 26 module:hook("client_management/new-client", function (event) | |
| 27 local session, client = event.session, event.client; | |
| 28 | |
| 29 local client_info = st.stanza("client", { id = client.id }); | |
| 30 if client.user_agent then | |
| 31 client_info:text_tag("agent", client.user_agent); | |
| 32 end | |
| 33 if client.legacy then | |
| 34 client_info:text_tag("legacy"); | |
| 35 end | |
| 36 | |
| 37 module:audit(jid.join(session.username, module.host), "new-client", { | |
| 38 session = session; | |
| 39 custom = { | |
| 40 }; | |
| 41 }); | |
| 42 end); |
