Comparison

core/usermanager.lua @ 10634:c9e1cb7a38b8

usermanager: Load authz providers on components also
author Matthew Wild <mwild1@gmail.com>
date Mon, 27 Jan 2020 22:09:19 +0000
parent 10633:d1cc6af0fb97
child 10635:675d9fbcbaed
comparison
equal deleted inserted replaced
10633:d1cc6af0fb97 10634:c9e1cb7a38b8
53 53
54 local provider_mt = { __index = new_null_provider() }; 54 local provider_mt = { __index = new_null_provider() };
55 55
56 local function initialize_host(host) 56 local function initialize_host(host)
57 local host_session = hosts[host]; 57 local host_session = hosts[host];
58
59 local authz_provider_name = config.get(host, "authorization") or "internal";
60
61 local authz_mod = modulemanager.load(host, "authz_"..authz_provider_name);
62 host_session.authz = authz_mod or global_authz_provider;
63
58 if host_session.type ~= "local" then return; end 64 if host_session.type ~= "local" then return; end
59 65
60 host_session.events.add_handler("item-added/auth-provider", function (event) 66 host_session.events.add_handler("item-added/auth-provider", function (event)
61 local provider = event.item; 67 local provider = event.item;
62 local auth_provider = config.get(host, "authentication") or default_provider; 68 local auth_provider = config.get(host, "authentication") or default_provider;
82 if config.get(host, "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7 88 if config.get(host, "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7
83 if auth_provider ~= "null" then 89 if auth_provider ~= "null" then
84 modulemanager.load(host, "auth_"..auth_provider); 90 modulemanager.load(host, "auth_"..auth_provider);
85 end 91 end
86 92
87 local authz_provider_name = config.get(host, "authorization") or "internal";
88
89 local authz_mod = modulemanager.load(host, "authz_"..authz_provider_name);
90 host_session.authz = authz_mod or global_authz_provider;
91 end; 93 end;
92 prosody.events.add_handler("host-activated", initialize_host, 100); 94 prosody.events.add_handler("host-activated", initialize_host, 100);
93 95
94 local function test_password(username, host, password) 96 local function test_password(username, host, password)
95 return hosts[host].users.test_password(username, password); 97 return hosts[host].users.test_password(username, password);