Software /
code /
prosody
Changeset
10916:c7ed8f754033
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 06 Jun 2020 00:54:28 +0200 |
parents | 10915:687273948ec7 (current diff) 10914:0d7d71dee0a0 (diff) |
children | 10917:1eb83bc6f706 |
files | plugins/mod_auth_internal_hashed.lua util/sasl/scram.lua |
diffstat | 5 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_auth_insecure.lua Sat Jun 06 00:49:48 2020 +0200 +++ b/plugins/mod_auth_insecure.lua Sat Jun 06 00:54:28 2020 +0200 @@ -9,6 +9,7 @@ local datamanager = require "util.datamanager"; local new_sasl = require "util.sasl".new; +local saslprep = require "util.encodings".stringprep.saslprep; local host = module.host; local provider = { name = "insecure" }; @@ -21,6 +22,10 @@ function provider.set_password(username, password) local account = datamanager.load(username, host, "accounts"); + password = saslprep(password); + if not password then + return nil, "Password fails SASLprep."; + end if account then account.password = password; return datamanager.store(username, host, "accounts", account);
--- 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
--- a/plugins/mod_auth_internal_plain.lua Sat Jun 06 00:49:48 2020 +0200 +++ b/plugins/mod_auth_internal_plain.lua Sat Jun 06 00:54:28 2020 +0200 @@ -8,6 +8,7 @@ local usermanager = require "core.usermanager"; local new_sasl = require "util.sasl".new; +local saslprep = require "util.encodings".stringprep.saslprep; local log = module._log; local host = module.host; @@ -20,8 +21,12 @@ 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 password == credentials.password then + if password == saslprep(credentials.password) then return true; else return nil, "Auth failed. Invalid username or password."; @@ -35,6 +40,10 @@ function provider.set_password(username, password) log("debug", "set_password for username '%s'", username); + password = saslprep(password); + if not password then + return nil, "Password fails SASLprep."; + end local account = accounts:get(username); if account then account.password = password; @@ -57,6 +66,10 @@ end function provider.create_user(username, password) + password = saslprep(password); + if not password then + return nil, "Password fails SASLprep."; + end return accounts:set(username, {password = password}); end
--- a/util/sasl/plain.lua Sat Jun 06 00:49:48 2020 +0200 +++ b/util/sasl/plain.lua Sat Jun 06 00:54:28 2020 +0200 @@ -70,7 +70,7 @@ if self.profile.plain then local correct_password; correct_password, state = self.profile.plain(self, authentication, self.realm); - correct = (correct_password == password); + correct = (saslprep(correct_password) == password); elseif self.profile.plain_test then correct, state = self.profile.plain_test(self, authentication, password, self.realm); end
--- a/util/sasl/scram.lua Sat Jun 06 00:49:48 2020 +0200 +++ b/util/sasl/scram.lua Sat Jun 06 00:54:28 2020 +0200 @@ -105,6 +105,10 @@ if iteration_count < 4096 then log("warn", "Iteration count < 4096 which is the suggested minimum according to RFC 5802.") end + password = saslprep(password); + if not password then + return false, "password fails SASLprep"; + end local salted_password = Hi(password, salt, iteration_count); local stored_key = H(HMAC(salted_password, "Client Key")) local server_key = HMAC(salted_password, "Server Key");