mod_s2s: Handle authentication of s2sin and s2sout the same way
[prosody.git] / plugins / mod_auth_insecure.lua
blob9e23c29fba0f89d43c492e2ddb06cb8a5d3d22a4
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 -- luacheck: ignore 212
10 local datamanager = require "util.datamanager";
11 local new_sasl = require "util.sasl".new;
13 local host = module.host;
14 local provider = { name = "insecure" };
16 assert(module:get_option_string("insecure_open_authentication") == "Yes please, I know what I'm doing!");
18 function provider.test_password(username, password)
19 return true;
20 end
22 function provider.set_password(username, password)
23 local account = datamanager.load(username, host, "accounts");
24 if account then
25 account.password = password;
26 return datamanager.store(username, host, "accounts", account);
27 end
28 return nil, "Account not available.";
29 end
31 function provider.user_exists(username)
32 return true;
33 end
35 function provider.create_user(username, password)
36 return datamanager.store(username, host, "accounts", {password = password});
37 end
39 function provider.delete_user(username)
40 return datamanager.store(username, host, "accounts", nil);
41 end
43 function provider.get_sasl_handler()
44 local getpass_authentication_profile = {
45 plain_test = function(sasl, username, password, realm)
46 return true, true;
47 end
49 return new_sasl(module.host, getpass_authentication_profile);
50 end
52 module:add_item("auth-provider", provider);