Comparison

plugins/mod_auth_anonymous.lua @ 5115:3939960b3c07

mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 12 Sep 2012 21:32:12 +0500
parent 4947:6d9317ea79b2
child 5117:2c7e1ce8f482
comparison
equal deleted inserted replaced
5113:3393cab2dd6b 5115:3939960b3c07
7 -- 7 --
8 8
9 local new_sasl = require "util.sasl".new; 9 local new_sasl = require "util.sasl".new;
10 local datamanager = require "util.datamanager"; 10 local datamanager = require "util.datamanager";
11 11
12 function new_default_provider(host) 12 -- define auth provider
13 local provider = { name = "anonymous" }; 13 local provider = { name = "anonymous" };
14 14
15 function provider.test_password(username, password) 15 function provider.test_password(username, password)
16 return nil, "Password based auth not supported."; 16 return nil, "Password based auth not supported.";
17 end
18
19 function provider.get_password(username)
20 return nil, "Password not available.";
21 end
22
23 function provider.set_password(username, password)
24 return nil, "Password based auth not supported.";
25 end
26
27 function provider.user_exists(username)
28 return nil, "Only anonymous users are supported."; -- FIXME check if anonymous user is connected?
29 end
30
31 function provider.create_user(username, password)
32 return nil, "Account creation/modification not supported.";
33 end
34
35 function provider.get_sasl_handler()
36 local anonymous_authentication_profile = {
37 anonymous = function(sasl, username, realm)
38 return true; -- for normal usage you should always return true here
39 end
40 };
41 return new_sasl(module.host, anonymous_authentication_profile);
42 end
43
44 return provider;
45 end 17 end
46 18
19 function provider.get_password(username)
20 return nil, "Password not available.";
21 end
22
23 function provider.set_password(username, password)
24 return nil, "Password based auth not supported.";
25 end
26
27 function provider.user_exists(username)
28 return nil, "Only anonymous users are supported."; -- FIXME check if anonymous user is connected?
29 end
30
31 function provider.create_user(username, password)
32 return nil, "Account creation/modification not supported.";
33 end
34
35 function provider.get_sasl_handler()
36 local anonymous_authentication_profile = {
37 anonymous = function(sasl, username, realm)
38 return true; -- for normal usage you should always return true here
39 end
40 };
41 return new_sasl(module.host, anonymous_authentication_profile);
42 end
43
44 -- datamanager callback to disable writes
47 local function dm_callback(username, host, datastore, data) 45 local function dm_callback(username, host, datastore, data)
48 if host == module.host then 46 if host == module.host then
49 return false; 47 return false;
50 end 48 end
51 return username, host, datastore, data; 49 return username, host, datastore, data;
62 end 60 end
63 function module.unload() 61 function module.unload()
64 datamanager.remove_callback(dm_callback); 62 datamanager.remove_callback(dm_callback);
65 end 63 end
66 64
67 module:add_item("auth-provider", new_default_provider(module.host)); 65 module:add_item("auth-provider", provider);
68 66