Software / code / prosody
Comparison
plugins/mod_auth_internal.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 |
|---|---|
| 14 local ipairs = ipairs; | 14 local ipairs = ipairs; |
| 15 local hashes = require "util.hashes"; | 15 local hashes = require "util.hashes"; |
| 16 local jid_bare = require "util.jid".bare; | 16 local jid_bare = require "util.jid".bare; |
| 17 local config = require "core.configmanager"; | 17 local config = require "core.configmanager"; |
| 18 local usermanager = require "core.usermanager"; | 18 local usermanager = require "core.usermanager"; |
| 19 local new_sasl = require "util.sasl".new; | |
| 20 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
| 19 local hosts = hosts; | 21 local hosts = hosts; |
| 20 | 22 |
| 21 local prosody = _G.prosody; | 23 local prosody = _G.prosody; |
| 22 | 24 |
| 23 local is_cyrus = usermanager.is_cyrus; | 25 local is_cyrus = usermanager.is_cyrus; |
| 71 function provider.create_user(username, password) | 73 function provider.create_user(username, password) |
| 72 if is_cyrus(host) then return nil, "Account creation/modification not available with Cyrus SASL."; end | 74 if is_cyrus(host) then return nil, "Account creation/modification not available with Cyrus SASL."; end |
| 73 return datamanager.store(username, host, "accounts", {password = password}); | 75 return datamanager.store(username, host, "accounts", {password = password}); |
| 74 end | 76 end |
| 75 | 77 |
| 76 function provider.get_supported_methods() | 78 function provider.get_sasl_handler() |
| 77 return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config | 79 local realm = module:get_option("sasl_realm") or origin.host; |
| 80 local getpass_authentication_profile = { | |
| 81 plain = function(username, realm) | |
| 82 local prepped_username = nodeprep(username); | |
| 83 if not prepped_username then | |
| 84 log("debug", "NODEprep failed on username: %s", username); | |
| 85 return "", nil; | |
| 86 end | |
| 87 local password = usermanager.get_password(prepped_username, realm); | |
| 88 if not password then | |
| 89 return "", nil; | |
| 90 end | |
| 91 return password, true; | |
| 92 end | |
| 93 }; | |
| 94 return new_sasl(realm, getpass_authentication_profile); | |
| 78 end | 95 end |
| 79 | 96 |
| 80 function provider.is_admin(jid) | 97 function provider.is_admin(jid) |
| 81 local admins = config.get(host, "core", "admins"); | 98 local admins = config.get(host, "core", "admins"); |
| 82 if admins ~= config.get("*", "core", "admins") and type(admins) == "table" then | 99 if admins ~= config.get("*", "core", "admins") and type(admins) == "table" then |