Software /
code /
prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 10916:c7ed8f754033
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 06 Jun 2020 00:54:28 +0200 |
parent | 10563:e8db377a2983 |
parent | 10914:0d7d71dee0a0 |
child | 11560:3bbb1af92514 |
comparison
equal
deleted
inserted
replaced
10915:687273948ec7 | 10916:c7ed8f754033 |
---|---|
13 local usermanager = require "core.usermanager"; | 13 local usermanager = require "core.usermanager"; |
14 local generate_uuid = require "util.uuid".generate; | 14 local generate_uuid = require "util.uuid".generate; |
15 local new_sasl = require "util.sasl".new; | 15 local new_sasl = require "util.sasl".new; |
16 local hex = require"util.hex"; | 16 local hex = require"util.hex"; |
17 local to_hex, from_hex = hex.to, hex.from; | 17 local to_hex, from_hex = hex.to, hex.from; |
18 local saslprep = require "util.encodings".stringprep.saslprep; | |
18 | 19 |
19 local log = module._log; | 20 local log = module._log; |
20 local host = module.host; | 21 local host = module.host; |
21 | 22 |
22 local accounts = module:open_store("accounts"); | 23 local accounts = module:open_store("accounts"); |
32 local provider = {}; | 33 local provider = {}; |
33 | 34 |
34 function provider.test_password(username, password) | 35 function provider.test_password(username, password) |
35 log("debug", "test password for user '%s'", username); | 36 log("debug", "test password for user '%s'", username); |
36 local credentials = accounts:get(username) or {}; | 37 local credentials = accounts:get(username) or {}; |
38 password = saslprep(password); | |
39 if not password then | |
40 return nil, "Password fails SASLprep."; | |
41 end | |
37 | 42 |
38 if credentials.password ~= nil and string.len(credentials.password) ~= 0 then | 43 if credentials.password ~= nil and string.len(credentials.password) ~= 0 then |
39 if credentials.password ~= password then | 44 if saslprep(credentials.password) ~= password then |
40 return nil, "Auth failed. Provided password is incorrect."; | 45 return nil, "Auth failed. Provided password is incorrect."; |
41 end | 46 end |
42 | 47 |
43 if provider.set_password(username, credentials.password) == nil then | 48 if provider.set_password(username, credentials.password) == nil then |
44 return nil, "Auth failed. Could not set hashed password from plaintext."; | 49 return nil, "Auth failed. Could not set hashed password from plaintext."; |