Diff

plugins/mod_legacyauth.lua @ 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
parent 1042:a3d77353c18a
child 1218:8e02c10c9e60
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");