Software / code / prosody
Comparison
core/usermanager.lua @ 3064:596303990c7c
usermanager, mod_saslauth: Make account provisioning for Cyrus SASL optional (default: not required)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 20 May 2010 11:32:24 +0100 |
| parent | 2934:060bb8217fea |
| child | 3065:0b8bd6f6a9c7 |
| child | 3113:30896751dd43 |
comparison
equal
deleted
inserted
replaced
| 3063:ca149818083d | 3064:596303990c7c |
|---|---|
| 13 local ipairs = ipairs; | 13 local ipairs = ipairs; |
| 14 local hashes = require "util.hashes"; | 14 local hashes = require "util.hashes"; |
| 15 local jid_bare = require "util.jid".bare; | 15 local jid_bare = require "util.jid".bare; |
| 16 local config = require "core.configmanager"; | 16 local config = require "core.configmanager"; |
| 17 local hosts = hosts; | 17 local hosts = hosts; |
| 18 | |
| 19 local require_provisioning = config.get("*", "core", "cyrus_require_provisioning") or false; | |
| 18 | 20 |
| 19 module "usermanager" | 21 module "usermanager" |
| 20 | 22 |
| 21 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end | 23 local function is_cyrus(host) return config.get(host, "core", "sasl_backend") == "cyrus"; end |
| 22 | 24 |
| 64 end | 66 end |
| 65 return nil, "Account not available."; | 67 return nil, "Account not available."; |
| 66 end | 68 end |
| 67 | 69 |
| 68 function user_exists(username, host) | 70 function user_exists(username, host) |
| 69 if is_cyrus(host) then return true; end | 71 if not(require_provisioning) and is_cyrus(host) then return true; end |
| 70 return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials | 72 return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials |
| 71 end | 73 end |
| 72 | 74 |
| 73 function create_user(username, password, host) | 75 function create_user(username, password, host) |
| 74 if is_cyrus(host) then return nil, "Account creation/modification not available with Cyrus SASL."; end | 76 if not(require_provisioning) and is_cyrus(host) then return nil, "Account creation/modification not available with Cyrus SASL."; end |
| 75 return datamanager.store(username, host, "accounts", {password = password}); | 77 return datamanager.store(username, host, "accounts", {password = password}); |
| 76 end | 78 end |
| 77 | 79 |
| 78 function get_supported_methods(host) | 80 function get_supported_methods(host) |
| 79 return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config | 81 return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config |