# HG changeset patch # User Kim Alvefur # Date 1413894932 -7200 # Node ID 8ad74f48b2aa98ba7f865a8fd629d37d434f7c5b # Parent 1f07c72112d2011b3ceac23d8a0a196c2bc62f18 mod_saslauth: Use a configurable set of mechanisms to not allow over unencrypted connections diff -r 1f07c72112d2 -r 8ad74f48b2aa plugins/mod_saslauth.lua --- a/plugins/mod_saslauth.lua Tue Oct 21 12:57:56 2014 +0200 +++ b/plugins/mod_saslauth.lua Tue Oct 21 14:35:32 2014 +0200 @@ -18,6 +18,7 @@ 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 @@ 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 @@ 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