mod_http: Fix traceback when no HTTP services succeed in binding
[prosody.git] / plugins / mod_auth_anonymous.lua
index 9d0896e5b16e8a7c25ff5c88c0a6eca78c6fcd4e..c080177d5fb4ebfeac62044224de0133bb6338f5 100644 (file)
@@ -6,7 +6,6 @@
 -- COPYING file in the source package for more information.
 --
 
-local log = require "util.logger".init("auth_anonymous");
 local new_sasl = require "util.sasl".new;
 local datamanager = require "util.datamanager";
 
@@ -34,13 +33,12 @@ function new_default_provider(host)
        end
 
        function provider.get_sasl_handler()
-               local realm = module:get_option("sasl_realm") or module.host;
                local anonymous_authentication_profile = {
                        anonymous = function(sasl, username, realm)
                                return true; -- for normal usage you should always return true here
                        end
                };
-               return new_sasl(realm, anonymous_authentication_profile);
+               return new_sasl(module.host, anonymous_authentication_profile);
        end
 
        return provider;
@@ -52,15 +50,17 @@ local function dm_callback(username, host, datastore, data)
        end
        return username, host, datastore, data;
 end
-local host = hosts[module.host];
-local _saved_disallow_s2s = host.disallow_s2s;
+
+if not module:get_option_boolean("allow_anonymous_s2s", false) then
+       module:hook("route/remote", function (event)
+               return false; -- Block outgoing s2s from anonymous users
+       end, 300);
+end
+
 function module.load()
-       _saved_disallow_s2s = host.disallow_s2s;
-       host.disallow_s2s = module:get_option("disallow_s2s") ~= false;
        datamanager.add_callback(dm_callback);
 end
 function module.unload()
-       host.disallow_s2s = _saved_disallow_s2s;
        datamanager.remove_callback(dm_callback);
 end