Software /
code /
prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 3186:b5f261123013
mod_auth_internal, mod_auth_internal_hashed: Updated to provide get_sasl_handler.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 07 Jun 2010 02:33:40 +0500 |
parent | 3180:99be525bcfb4 |
child | 3187:a475fbce1990 |
comparison
equal
deleted
inserted
replaced
3185:09174a6e8366 | 3186:b5f261123013 |
---|---|
16 local jid_bare = require "util.jid".bare; | 16 local jid_bare = require "util.jid".bare; |
17 local saltedPasswordSHA1 = require "util.sasl.scram".saltedPasswordSHA1; | 17 local saltedPasswordSHA1 = require "util.sasl.scram".saltedPasswordSHA1; |
18 local config = require "core.configmanager"; | 18 local config = require "core.configmanager"; |
19 local usermanager = require "core.usermanager"; | 19 local usermanager = require "core.usermanager"; |
20 local generate_uuid = require "util.uuid".generate; | 20 local generate_uuid = require "util.uuid".generate; |
21 local new_sasl = require "util.sasl".new; | |
22 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
21 local hosts = hosts; | 23 local hosts = hosts; |
22 | 24 |
23 local prosody = _G.prosody; | 25 local prosody = _G.prosody; |
24 | 26 |
25 local is_cyrus = usermanager.is_cyrus; | 27 local is_cyrus = usermanager.is_cyrus; |
103 local valid, binpass = saltedPasswordSHA1(password, salt, iteration_count); | 105 local valid, binpass = saltedPasswordSHA1(password, salt, iteration_count); |
104 local hexpass = binpass:gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 106 local hexpass = binpass:gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
105 return datamanager.store(username, host, "accounts", {hashpass = hexpass, salt = salt, iteration_count = iteration_count}); | 107 return datamanager.store(username, host, "accounts", {hashpass = hexpass, salt = salt, iteration_count = iteration_count}); |
106 end | 108 end |
107 | 109 |
108 function provider.get_supported_methods() | 110 function provider.get_sasl_handler() |
109 return {["PLAIN"] = true}; -- TODO this should be taken from the config | 111 local realm = module:get_option("sasl_realm") or origin.host; |
112 local testpass_authentication_profile = { | |
113 plain_test = function(username, password, realm) | |
114 local prepped_username = nodeprep(username); | |
115 if not prepped_username then | |
116 log("debug", "NODEprep failed on username: %s", username); | |
117 return "", nil; | |
118 end | |
119 return usermanager.test_password(prepped_username, password, realm), true; | |
120 end | |
121 }; | |
122 return new_sasl(realm, testpass_authentication_profile); | |
110 end | 123 end |
111 | 124 |
112 function provider.is_admin(jid) | 125 function provider.is_admin(jid) |
113 local admins = config.get(host, "core", "admins"); | 126 local admins = config.get(host, "core", "admins"); |
114 if admins ~= config.get("*", "core", "admins") and type(admins) == "table" then | 127 if admins ~= config.get("*", "core", "admins") and type(admins) == "table" then |