Diff

plugins/mod_auth_internal_hashed.lua @ 10914:0d7d71dee0a0 0.11

mod_auth_internal_*: Apply saslprep to passwords Related to #1560
author Kim Alvefur <zash@zash.se>
date Sat, 23 May 2020 14:17:04 +0200
parent 10522:b1ca849b8e3a
child 10916:c7ed8f754033
child 11544:c98aebe601f9
line wrap: on
line diff
--- a/plugins/mod_auth_internal_hashed.lua	Fri May 22 21:05:45 2020 +0200
+++ b/plugins/mod_auth_internal_hashed.lua	Sat May 23 14:17:04 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;
@@ -32,9 +33,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