# HG changeset patch # User Waqas Hussain # Date 1276126506 -18000 # Node ID 75a85eac3c274b6f69c2fdebc73f2d8d1428664d # Parent fd8d76daad9719c48d0dde6c9961692eda987b4f mod_extauth: Updated to provide a SASL handler. diff -r fd8d76daad97 -r 75a85eac3c27 mod_extauth/mod_extauth.lua --- a/mod_extauth/mod_extauth.lua Sun Jun 06 00:04:04 2010 +0800 +++ b/mod_extauth/mod_extauth.lua Thu Jun 10 04:35:06 2010 +0500 @@ -24,6 +24,7 @@ assert(not host:find(":")); local usermanager = require "core.usermanager"; local jid_bare = require "util.jid".bare; +local new_sasl = require "util.sasl".new; --local proc; local pid; @@ -104,7 +105,20 @@ function provider.create_user(username, password) return nil, "Account creation/modification not available."; end - function provider.get_supported_methods() return {["PLAIN"] = true}; end + function provider.get_sasl_handler() + local realm = module:get_option("sasl_realm") or module.host; + local testpass_authentication_profile = { + plain_test = function(username, password, realm) + local prepped_username = nodeprep(username); + if not prepped_username then + log("debug", "NODEprep failed on username: %s", username); + return "", nil; + end + return usermanager.test_password(prepped_username, password, realm), true; + end, + }; + return new_sasl(realm, testpass_authentication_profile); + end function provider.is_admin(jid) local admins = config.get(host, "core", "admins");