-function validate_credentials(host, username, password, method)
- log("debug", "User '%s' is being validated", username);
- local credentials = datamanager.load(username, host, "accounts") or {};
- if method == nil then method = "PLAIN"; end
- if method == "PLAIN" and credentials.password then -- PLAIN, do directly
- if password == credentials.password then
- return true;
- else
- return nil, "Auth failed. Invalid username or password.";
+function new_null_provider()
+ local function dummy() return nil, "method not implemented"; end;
+ local function dummy_get_sasl_handler() return sasl_new(nil, {}); end
+ return setmetatable({name = "null", get_sasl_handler = dummy_get_sasl_handler}, {
+ __index = function(self, method) return dummy; end
+ });
+end
+
+local provider_mt = { __index = new_null_provider() };
+
+function initialize_host(host)
+ local host_session = hosts[host];
+ if host_session.type ~= "local" then return; end
+
+ host_session.events.add_handler("item-added/auth-provider", function (event)
+ local provider = event.item;
+ local auth_provider = config.get(host, "core", "authentication") or default_provider;
+ if config.get(host, "core", "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7
+ if provider.name == auth_provider then
+ host_session.users = setmetatable(provider, provider_mt);