aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_auth_internal_hashed.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-05-23 14:17:04 +0200
committerKim Alvefur <zash@zash.se>2020-05-23 14:17:04 +0200
commit71c6728e69c98d7a70ec4ae4ffacb08ae683803f (patch)
treea249dec1a21ea653597ecba2e941089a3f886369 /plugins/mod_auth_internal_hashed.lua
parenta7083d1dedda96bce48c84a5f348c10714ff7d69 (diff)
downloadprosody-71c6728e69c98d7a70ec4ae4ffacb08ae683803f.tar.gz
prosody-71c6728e69c98d7a70ec4ae4ffacb08ae683803f.zip
mod_auth_internal_*: Apply saslprep to passwords
Related to #1560
Diffstat (limited to 'plugins/mod_auth_internal_hashed.lua')
-rw-r--r--plugins/mod_auth_internal_hashed.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua
index 083f648b..15058098 100644
--- a/plugins/mod_auth_internal_hashed.lua
+++ b/plugins/mod_auth_internal_hashed.lua
@@ -15,6 +15,7 @@ local generate_uuid = require "util.uuid".generate;
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 @@ local provider = {};
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