Merge 0.9->trunk
[prosody.git] / plugins / mod_auth_internal_hashed.lua
index cbca68618d5c05dce32c636c70c39951290ec216..cb6cc8ff6d3f922a253c6e0103ae7297e356fbb2 100644 (file)
@@ -13,7 +13,6 @@ local getAuthenticationDatabaseSHA1 = require "util.sasl.scram".getAuthenticatio
 local usermanager = require "core.usermanager";
 local generate_uuid = require "util.uuid".generate;
 local new_sasl = require "util.sasl".new;
-local nodeprep = require "util.encodings".stringprep.nodeprep;
 
 local to_hex;
 do
@@ -41,7 +40,7 @@ local iteration_count = 4096;
 
 local host = module.host;
 -- define auth provider
-local provider = { name = "internal_hashed" };
+local provider = {};
 log("debug", "initializing internal_hashed authentication provider for host '%s'", host);
 
 function provider.test_password(username, password)
@@ -102,6 +101,10 @@ function provider.user_exists(username)
        return true;
 end
 
+function provider.users()
+       return datamanager.users(host, "accounts");
+end
+
 function provider.create_user(username, password)
        if password == nil then
                return datamanager.store(username, host, "accounts", {});
@@ -120,12 +123,7 @@ end
 function provider.get_sasl_handler()
        local testpass_authentication_profile = {
                plain_test = function(sasl, username, password, realm)
-                       local prepped_username = nodeprep(username);
-                       if not prepped_username then
-                               log("debug", "NODEprep failed on username: %s", username);
-                               return "", nil;
-                       end
-                       return usermanager.test_password(prepped_username, realm, password), true;
+                       return usermanager.test_password(username, realm, password), true;
                end,
                scram_sha_1 = function(sasl, username, realm)
                        local credentials = datamanager.load(username, host, "accounts");
@@ -145,5 +143,5 @@ function provider.get_sasl_handler()
        return new_sasl(host, testpass_authentication_profile);
 end
        
-module:add_item("auth-provider", provider);
+module:provides("auth", provider);