Software /
code /
prosody
Changeset
1216:fd8ce71bc72b
mod_saslauth, mod_legacyauth: Deny logins to unsecure sessions when require_encryption config option is true
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 29 May 2009 14:33:55 +0100 |
parents | 1215:d3534badd748 |
children | 1217:844ef764ef0e |
files | plugins/mod_legacyauth.lua plugins/mod_saslauth.lua |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_legacyauth.lua Fri May 29 14:31:51 2009 +0100 +++ b/plugins/mod_legacyauth.lua Fri May 29 14:33:55 2009 +0100 @@ -11,6 +11,9 @@ local st = require "util.stanza"; local t_concat = table.concat; +local config = require "core.configmanager"; +local secure_auth_only = config.get(module:get_host(), "core", "require_encryption"); + local sessionmanager = require "core.sessionmanager"; local usermanager = require "core.usermanager"; @@ -21,6 +24,11 @@ module:add_iq_handler("c2s_unauthed", "jabber:iq:auth", function (session, stanza) + if secure_auth_only and not session.secure then + session.send(st.error_reply(stanza, "modify", "not-acceptable", "Encryption (SSL or TLS) is required to connect to this server")); + return true; + end + local username = stanza.tags[1]:child_with_name("username"); local password = stanza.tags[1]:child_with_name("password"); local resource = stanza.tags[1]:child_with_name("resource");
--- a/plugins/mod_saslauth.lua Fri May 29 14:31:51 2009 +0100 +++ b/plugins/mod_saslauth.lua Fri May 29 14:33:55 2009 +0100 @@ -21,6 +21,8 @@ local md5 = require "util.hashes".md5; local config = require "core.configmanager"; +local secure_auth_only = config.get(module:get_host(), "core", "require_encryption"); + local log = module._log; local xmlns_sasl ='urn:ietf:params:xml:ns:xmpp-sasl'; @@ -119,7 +121,7 @@ local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; module:add_event_hook("stream-features", function (session, features) - if not session.username then + if not session.username and ((not secure_auth_only) or session.secure) then features:tag("mechanisms", mechanisms_attr); -- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so. if config.get(session.host or "*", "core", "anonymous_login") then