Mercurial > prosody-modules
changeset 166:75a85eac3c27
mod_extauth: Updated to provide a SASL handler.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 10 Jun 2010 04:35:06 +0500 (2010-06-09) |
parents | fd8d76daad97 |
children | 0d37d18ea073 |
files | mod_extauth/mod_extauth.lua |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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");