From ac43c71ec21ded1ae3a6ace3d9ce06995453e8ee Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 12:49:03 +0200 Subject: mod_legacyauth, mod_saslauth, mod_tls: Pass require_encryption as default option to s2s_require_encryption so the later overrides the former --- plugins/mod_legacyauth.lua | 4 ++-- plugins/mod_saslauth.lua | 2 +- plugins/mod_tls.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_legacyauth.lua b/plugins/mod_legacyauth.lua index 54cbec24..5edc26bb 100644 --- a/plugins/mod_legacyauth.lua +++ b/plugins/mod_legacyauth.lua @@ -11,8 +11,8 @@ local st = require "util.stanza"; local t_concat = table.concat; -local secure_auth_only = module:get_option("c2s_require_encryption") - or module:get_option("require_encryption") +local secure_auth_only = module:get_option("c2s_require_encryption", + module:get_option("require_encryption")) or not(module:get_option("allow_unencrypted_plain_auth")); local sessionmanager = require "core.sessionmanager"; diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 9e63b4c7..1cd944b0 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -16,7 +16,7 @@ local base64 = require "util.encodings".base64; local usermanager_get_sasl_handler = require "core.usermanager".get_sasl_handler; local tostring = tostring; -local secure_auth_only = module:get_option("c2s_require_encryption") or module:get_option("require_encryption"); +local secure_auth_only = module:get_option("c2s_require_encryption", module:get_option("require_encryption")); local allow_unencrypted_plain_auth = module:get_option("allow_unencrypted_plain_auth") local log = module._log; diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 351aaffc..f2d76c38 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -9,7 +9,7 @@ local create_context = require "core.certmanager".create_context; local st = require "util.stanza"; -local c2s_require_encryption = module:get_option("c2s_require_encryption") or module:get_option("require_encryption"); +local c2s_require_encryption = module:get_option("c2s_require_encryption", module:get_option("require_encryption")); local s2s_require_encryption = module:get_option("s2s_require_encryption"); local allow_s2s_tls = module:get_option("s2s_allow_encryption") ~= false; local s2s_secure_auth = module:get_option("s2s_secure_auth"); -- cgit v1.2.3 From bf13e6d88e94227b690654fa385fc342613908df Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 12:56:19 +0200 Subject: mod_saslauth: Use type-specific config option getters --- plugins/mod_saslauth.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 1cd944b0..af3a5fec 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -16,8 +16,8 @@ local base64 = require "util.encodings".base64; local usermanager_get_sasl_handler = require "core.usermanager".get_sasl_handler; local tostring = tostring; -local secure_auth_only = module:get_option("c2s_require_encryption", module:get_option("require_encryption")); -local allow_unencrypted_plain_auth = module:get_option("allow_unencrypted_plain_auth") +local secure_auth_only = module:get_option_boolean("c2s_require_encryption", module:get_option_boolean("require_encryption", false)); +local allow_unencrypted_plain_auth = module:get_option_boolean("allow_unencrypted_plain_auth", false) local log = module._log; -- cgit v1.2.3 From 371d996a7d0b32e617611b40faa9f2d8988dbd53 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 12:57:56 +0200 Subject: mod_saslauth: Log warning if no SASL mechanisms were offered --- plugins/mod_saslauth.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index af3a5fec..1820dce3 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -235,7 +235,11 @@ module:hook("stream-features", function(event) mechanisms:tag("mechanism"):text(mechanism):up(); end end - if mechanisms[1] then features:add_child(mechanisms); end + if mechanisms[1] then + features:add_child(mechanisms); + else + (origin.log or log)("warn", "No SASL mechanisms to offer"); + end else features:tag("bind", bind_attr):tag("required"):up():up(); features:tag("session", xmpp_session_attr):tag("optional"):up():up(); -- cgit v1.2.3 From 73979a83fdb1a17f4ed04c1ca979ac4ca74f7dc6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 14:35:32 +0200 Subject: mod_saslauth: Use a configurable set of mechanisms to not allow over unencrypted connections --- plugins/mod_saslauth.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 1820dce3..edc151a6 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -18,6 +18,7 @@ local tostring = tostring; local secure_auth_only = module:get_option_boolean("c2s_require_encryption", module:get_option_boolean("require_encryption", false)); local allow_unencrypted_plain_auth = module:get_option_boolean("allow_unencrypted_plain_auth", false) +local insecure_mechanisms = module:get_option_set("allow_unencrypted_sasl", allow_unencrypted_plain_auth and {} or {"PLAIN"}); local log = module._log; @@ -183,7 +184,7 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:auth", function(event) session.sasl_handler = usermanager_get_sasl_handler(module.host, session); end local mechanism = stanza.attr.mechanism; - if not session.secure and (secure_auth_only or (mechanism == "PLAIN" and not allow_unencrypted_plain_auth)) then + if not session.secure and (secure_auth_only or insecure_mechanisms:contains(mechanism)) then session.send(build_reply("failure", "encryption-required")); return true; end @@ -231,7 +232,7 @@ module:hook("stream-features", function(event) end local mechanisms = st.stanza("mechanisms", mechanisms_attr); for mechanism in pairs(origin.sasl_handler:mechanisms()) do - if mechanism ~= "PLAIN" or origin.secure or allow_unencrypted_plain_auth then + if (origin.secure or not insecure_mechanisms:contains(mechanism)) then mechanisms:tag("mechanism"):text(mechanism):up(); end end -- cgit v1.2.3 From 83b74ac626e04c60e3b724cf26f29d81b8b81248 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 14:37:05 +0200 Subject: mod_saslauth: Add LOGIN to mechanisms not allowed over unencrypted connections as it may be offered by 3rd party authentication plugins --- plugins/mod_saslauth.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index edc151a6..52144175 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -18,7 +18,7 @@ local tostring = tostring; local secure_auth_only = module:get_option_boolean("c2s_require_encryption", module:get_option_boolean("require_encryption", false)); local allow_unencrypted_plain_auth = module:get_option_boolean("allow_unencrypted_plain_auth", false) -local insecure_mechanisms = module:get_option_set("allow_unencrypted_sasl", allow_unencrypted_plain_auth and {} or {"PLAIN"}); +local insecure_mechanisms = module:get_option_set("allow_unencrypted_sasl", allow_unencrypted_plain_auth and {} or {"PLAIN", "LOGIN"}); local log = module._log; -- cgit v1.2.3 From 1386a2c85d914325281901285df54ca44409a957 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 14:38:40 +0200 Subject: mod_saslauth: Make it possible to disable certain mechanisms --- plugins/mod_saslauth.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 52144175..a664a8ed 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -19,6 +19,7 @@ local tostring = tostring; local secure_auth_only = module:get_option_boolean("c2s_require_encryption", module:get_option_boolean("require_encryption", false)); local allow_unencrypted_plain_auth = module:get_option_boolean("allow_unencrypted_plain_auth", false) local insecure_mechanisms = module:get_option_set("allow_unencrypted_sasl", allow_unencrypted_plain_auth and {} or {"PLAIN", "LOGIN"}); +local disabled_mechanisms = module:get_option_set("disable_sasl_mechanisms", {}); local log = module._log; @@ -187,6 +188,9 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:auth", function(event) if not session.secure and (secure_auth_only or insecure_mechanisms:contains(mechanism)) then session.send(build_reply("failure", "encryption-required")); return true; + elseif disabled_mechanisms:contains(mechanism) then + session.send(build_reply("failure", "invalid-mechanism")); + return true; end local valid_mechanism = session.sasl_handler:select(mechanism); if not valid_mechanism then @@ -232,7 +236,7 @@ module:hook("stream-features", function(event) end local mechanisms = st.stanza("mechanisms", mechanisms_attr); for mechanism in pairs(origin.sasl_handler:mechanisms()) do - if (origin.secure or not insecure_mechanisms:contains(mechanism)) then + if (not disabled_mechanisms:contains(mechanism)) and (origin.secure or not insecure_mechanisms:contains(mechanism)) then mechanisms:tag("mechanism"):text(mechanism):up(); end end -- cgit v1.2.3 From 9722fc8c01da68e26c605377dd6b3347def9d3c8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Oct 2014 16:41:28 +0200 Subject: mod_saslauth: Better name for config option --- plugins/mod_saslauth.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index a664a8ed..e42adbe1 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -18,7 +18,7 @@ local tostring = tostring; local secure_auth_only = module:get_option_boolean("c2s_require_encryption", module:get_option_boolean("require_encryption", false)); local allow_unencrypted_plain_auth = module:get_option_boolean("allow_unencrypted_plain_auth", false) -local insecure_mechanisms = module:get_option_set("allow_unencrypted_sasl", allow_unencrypted_plain_auth and {} or {"PLAIN", "LOGIN"}); +local insecure_mechanisms = module:get_option_set("insecure_sasl_mechanisms", allow_unencrypted_plain_auth and {} or {"PLAIN", "LOGIN"}); local disabled_mechanisms = module:get_option_set("disable_sasl_mechanisms", {}); local log = module._log; -- cgit v1.2.3 From a5013be8b59a24101539f31e841477ae163e8624 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 25 Oct 2014 14:45:11 +0200 Subject: mod_blocklist: Only log message about migrating from mod_privacy when there is data to migrate --- plugins/mod_blocklist.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua index 1f09ca13..45415790 100644 --- a/plugins/mod_blocklist.lua +++ b/plugins/mod_blocklist.lua @@ -43,7 +43,6 @@ end -- Migrates from the old mod_privacy storage local function migrate_privacy_list(username) local migrated_data = { [false] = "not empty" }; - module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username); local legacy_data = module:open_store("privacy"):get(username); if legacy_data and legacy_data.lists and legacy_data.default then legacy_data = legacy_data.lists[legacy_data.default]; @@ -52,6 +51,7 @@ local function migrate_privacy_list(username) return migrated_data; end if legacy_data then + module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username); local item, jid; for i = 1, #legacy_data do item = legacy_data[i]; -- cgit v1.2.3 From d0cb0b35d5e1d3d12bf07610330c93e55eae086a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 26 Oct 2014 16:29:50 +0100 Subject: mod_blocklist: Don't send unavailable presence from unavailable sessions when blocking a contact --- plugins/mod_blocklist.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua index 45415790..70bfb5fc 100644 --- a/plugins/mod_blocklist.lua +++ b/plugins/mod_blocklist.lua @@ -149,7 +149,9 @@ local function edit_blocklist(event) for jid, in_roster in pairs(new) do if not blocklist[jid] and in_roster and sessions[username] then for _, session in pairs(sessions[username].sessions) do - module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid })); + if session.presence then + module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid })); + end end end end -- cgit v1.2.3