diff options
author | Kim Alvefur <zash@zash.se> | 2014-10-21 14:38:40 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-10-21 14:38:40 +0200 |
commit | 1386a2c85d914325281901285df54ca44409a957 (patch) | |
tree | 4480e10a8b3aea4fbda14e2ba80709cbe5d6c301 /plugins/mod_saslauth.lua | |
parent | 83b74ac626e04c60e3b724cf26f29d81b8b81248 (diff) | |
download | prosody-1386a2c85d914325281901285df54ca44409a957.tar.gz prosody-1386a2c85d914325281901285df54ca44409a957.zip |
mod_saslauth: Make it possible to disable certain mechanisms
Diffstat (limited to 'plugins/mod_saslauth.lua')
-rw-r--r-- | plugins/mod_saslauth.lua | 6 |
1 files changed, 5 insertions, 1 deletions
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 |