2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
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
)
22 function provider
.set_password(username
, password
)
23 local account
= datamanager
.load(username
, host
, "accounts");
25 account
.password
= password
;
26 return datamanager
.store(username
, host
, "accounts", account
);
28 return nil, "Account not available.";
31 function provider
.user_exists(username
)
35 function provider
.create_user(username
, password
)
36 return datamanager
.store(username
, host
, "accounts", {password
= password
});
39 function provider
.delete_user(username
)
40 return datamanager
.store(username
, host
, "accounts", nil);
43 function provider
.get_sasl_handler()
44 local getpass_authentication_profile
= {
45 plain_test
= function(sasl
, username
, password
, realm
)
49 return new_sasl(module
.host
, getpass_authentication_profile
);
52 module
:add_item("auth-provider", provider
);