Mercurial > prosody-modules
comparison mod_auth_any/mod_auth_any.lua @ 1294:bb1fb54360ab
mod_auth_any: Allows any username/password to connect
author | Waqas Hussain <waqas20@gmail.com>, Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 30 Jan 2014 20:31:18 -0500 |
parents | |
children | 7dbde05b48a9 |
comparison
equal
deleted
inserted
replaced
1293:ddbc1eb8d431 | 1294:bb1fb54360ab |
---|---|
1 -- Prosody IM | |
2 -- Copyright (C) 2008-2010 Matthew Wild | |
3 -- Copyright (C) 2008-2010 Waqas Hussain | |
4 -- | |
5 -- This project is MIT/X11 licensed. Please see the | |
6 -- COPYING file in the source package for more information. | |
7 -- | |
8 | |
9 local datamanager = require "util.datamanager"; | |
10 local log = require "util.logger".init("auth_any"); | |
11 local type = type; | |
12 local error = error; | |
13 local ipairs = ipairs; | |
14 local hashes = require "util.hashes"; | |
15 local jid_bare = require "util.jid".bare; | |
16 local config = require "core.configmanager"; | |
17 local usermanager = require "core.usermanager"; | |
18 local new_sasl = require "util.sasl".new; | |
19 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
20 local hosts = hosts; | |
21 | |
22 local prosody = _G.prosody; | |
23 | |
24 function new_default_provider(host) | |
25 local provider = { name = "any" }; | |
26 log("debug", "initializing default authentication provider for host '%s'", host); | |
27 | |
28 function provider.test_password(username, password) | |
29 return true; | |
30 end | |
31 | |
32 function provider.set_password(username, password) | |
33 local account = datamanager.load(username, host, "accounts"); | |
34 if account then | |
35 account.password = password; | |
36 return datamanager.store(username, host, "accounts", account); | |
37 end | |
38 return nil, "Account not available."; | |
39 end | |
40 | |
41 function provider.user_exists(username) | |
42 return true; | |
43 end | |
44 | |
45 function provider.create_user(username, password) | |
46 return datamanager.store(username, host, "accounts", {password = password}); | |
47 end | |
48 | |
49 function provider.delete_user(username) | |
50 return datamanager.store(username, host, "accounts", nil); | |
51 end | |
52 | |
53 function provider.get_sasl_handler() | |
54 local getpass_authentication_profile = { | |
55 plain_test = function(sasl, username, password, realm) | |
56 return true, true; | |
57 end | |
58 }; | |
59 return new_sasl(module.host, getpass_authentication_profile); | |
60 end | |
61 | |
62 return provider; | |
63 end | |
64 | |
65 module:add_item("auth-provider", new_default_provider(module.host)); | |
66 |