Software /
code /
prosody
Diff
tools/ejabberd2prosody.lua @ 6797:509b70437035
ejabberd2prosody: Support password stored as SCRAM hashes
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Aug 2015 09:14:15 +0200 |
parent | 6280:ce1a20bd2053 |
child | 6798:8b4c8e957211 |
line wrap: on
line diff
--- a/tools/ejabberd2prosody.lua Mon Aug 10 22:13:02 2015 +0200 +++ b/tools/ejabberd2prosody.lua Thu Aug 20 09:14:15 2015 +0200 @@ -72,7 +72,22 @@ print("["..(err or "success").."] vCard: "..node.."@"..host); end function password(node, host, password) - local ret, err = dm.store(node, host, "accounts", {password = password}); + local data = {}; + if type(password) == "string" then + data.password = password; + elseif type(password) == "table" and password[1] == "scram" then + local unb64 = require"mime".unb64; + local function hex(s) + return s:gsub(".", function (c) + return ("%02x"):format(c:byte()); + end); + end + data.stored_key = hex(unb64(password[2])); + data.server_key = hex(unb64(password[3])); + data.salt = unb64(password[4]); + data.iteration_count = password[5]; + end + local ret, err = dm.store(node, host, "accounts", data); print("["..(err or "success").."] accounts: "..node.."@"..host); end function roster(node, host, jid, item)