diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-06-07 12:21:57 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-06-07 12:21:57 +0100 |
commit | 1357c719b98ae25b8cc593005371d59dc5182c4d (patch) | |
tree | 1764ffb1eaed95676cb1191d8cc401e82979b1ff /plugins/mod_auth_internal.lua | |
parent | 798403ee6857266c11f288946e532a325697bdb4 (diff) | |
parent | d471482a87ac4914c3555f543e4c120bdb15467a (diff) | |
download | prosody-1357c719b98ae25b8cc593005371d59dc5182c4d.tar.gz prosody-1357c719b98ae25b8cc593005371d59dc5182c4d.zip |
Merge trunk/MattJ->trunk
Diffstat (limited to 'plugins/mod_auth_internal.lua')
-rw-r--r-- | plugins/mod_auth_internal.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/mod_auth_internal.lua b/plugins/mod_auth_internal.lua index 78a75a1d..1c426030 100644 --- a/plugins/mod_auth_internal.lua +++ b/plugins/mod_auth_internal.lua @@ -16,6 +16,8 @@ local hashes = require "util.hashes"; local jid_bare = require "util.jid".bare; local config = require "core.configmanager"; local usermanager = require "core.usermanager"; +local new_sasl = require "util.sasl".new; +local nodeprep = require "util.encodings".stringprep.nodeprep; local hosts = hosts; local prosody = _G.prosody; @@ -73,8 +75,23 @@ function new_default_provider(host) return datamanager.store(username, host, "accounts", {password = password}); end - function provider.get_supported_methods() - return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config + function provider.get_sasl_handler() + local realm = module:get_option("sasl_realm") or module.host; + local getpass_authentication_profile = { + plain = function(username, realm) + local prepped_username = nodeprep(username); + if not prepped_username then + log("debug", "NODEprep failed on username: %s", username); + return "", nil; + end + local password = usermanager.get_password(prepped_username, realm); + if not password then + return "", nil; + end + return password, true; + end + }; + return new_sasl(realm, getpass_authentication_profile); end function provider.is_admin(jid) |