Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
6773:ef22c17cc24d | 6797:509b70437035 |
---|---|
70 function vcard(node, host, stanza) | 70 function vcard(node, host, stanza) |
71 local ret, err = dm.store(node, host, "vcard", st.preserialize(stanza)); | 71 local ret, err = dm.store(node, host, "vcard", st.preserialize(stanza)); |
72 print("["..(err or "success").."] vCard: "..node.."@"..host); | 72 print("["..(err or "success").."] vCard: "..node.."@"..host); |
73 end | 73 end |
74 function password(node, host, password) | 74 function password(node, host, password) |
75 local ret, err = dm.store(node, host, "accounts", {password = password}); | 75 local data = {}; |
76 if type(password) == "string" then | |
77 data.password = password; | |
78 elseif type(password) == "table" and password[1] == "scram" then | |
79 local unb64 = require"mime".unb64; | |
80 local function hex(s) | |
81 return s:gsub(".", function (c) | |
82 return ("%02x"):format(c:byte()); | |
83 end); | |
84 end | |
85 data.stored_key = hex(unb64(password[2])); | |
86 data.server_key = hex(unb64(password[3])); | |
87 data.salt = unb64(password[4]); | |
88 data.iteration_count = password[5]; | |
89 end | |
90 local ret, err = dm.store(node, host, "accounts", data); | |
76 print("["..(err or "success").."] accounts: "..node.."@"..host); | 91 print("["..(err or "success").."] accounts: "..node.."@"..host); |
77 end | 92 end |
78 function roster(node, host, jid, item) | 93 function roster(node, host, jid, item) |
79 local roster = dm.load(node, host, "roster") or {}; | 94 local roster = dm.load(node, host, "roster") or {}; |
80 roster[jid] = item; | 95 roster[jid] = item; |