Comparison

plugins/mod_auth_anonymous.lua @ 11122:d60094d9b458

mod_auth_anonymous: Add config option to allow/disallow storage writes
author Matthew Wild <mwild1@gmail.com>
date Fri, 02 Oct 2020 16:44:30 +0100
parent 8053:7d26dab7ce0d
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
11121:2d38242a08dd 11122:d60094d9b458
8 -- luacheck: ignore 212 8 -- luacheck: ignore 212
9 9
10 local new_sasl = require "util.sasl".new; 10 local new_sasl = require "util.sasl".new;
11 local datamanager = require "util.datamanager"; 11 local datamanager = require "util.datamanager";
12 local hosts = prosody.hosts; 12 local hosts = prosody.hosts;
13
14 local allow_storage = module:get_option_boolean("allow_anonymous_storage", false);
13 15
14 -- define auth provider 16 -- define auth provider
15 local provider = {}; 17 local provider = {};
16 18
17 function provider.test_password(username, password) 19 function provider.test_password(username, password)
60 return false; -- Block outgoing s2s from anonymous users 62 return false; -- Block outgoing s2s from anonymous users
61 end, 300); 63 end, 300);
62 end 64 end
63 65
64 function module.load() 66 function module.load()
65 datamanager.add_callback(dm_callback); 67 if not allow_storage then
68 datamanager.add_callback(dm_callback);
69 end
66 end 70 end
67 function module.unload() 71 function module.unload()
68 datamanager.remove_callback(dm_callback); 72 if not allow_storage then
73 datamanager.remove_callback(dm_callback);
74 end
69 end 75 end
70 76
71 module:provides("auth", provider); 77 module:provides("auth", provider);
72 78