plugins/mod_auth_internal_hashed.lua
changeset 10920 c7ed8f754033
parent 10567 e8db377a2983
parent 10918 0d7d71dee0a0
child 11564 3bbb1af92514
--- a/plugins/mod_auth_internal_hashed.lua	Sat Jun 06 00:49:48 2020 +0200
+++ b/plugins/mod_auth_internal_hashed.lua	Sat Jun 06 00:54:28 2020 +0200
@@ -15,6 +15,7 @@
 local new_sasl = require "util.sasl".new;
 local hex = require"util.hex";
 local to_hex, from_hex = hex.to, hex.from;
+local saslprep = require "util.encodings".stringprep.saslprep;
 
 local log = module._log;
 local host = module.host;
@@ -34,9 +35,13 @@
 function provider.test_password(username, password)
 	log("debug", "test password for user '%s'", username);
 	local credentials = accounts:get(username) or {};
+	password = saslprep(password);
+	if not password then
+		return nil, "Password fails SASLprep.";
+	end
 
 	if credentials.password ~= nil and string.len(credentials.password) ~= 0 then
-		if credentials.password ~= password then
+		if saslprep(credentials.password) ~= password then
 			return nil, "Auth failed. Provided password is incorrect.";
 		end