Software /
code /
prosody
Comparison
plugins/mod_dialback.lua @ 6299:a1da78658a82
hostmanager, mod_dialback: Move generation of dialback secret out of core
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 22 May 2014 15:21:22 +0200 |
parent | 5778:8ea6fa8459e3 |
child | 6300:4b0172dc5e3a |
comparison
equal
deleted
inserted
replaced
6298:6ddd7913913b | 6299:a1da78658a82 |
---|---|
11 local log = module._log; | 11 local log = module._log; |
12 | 12 |
13 local st = require "util.stanza"; | 13 local st = require "util.stanza"; |
14 local sha256_hash = require "util.hashes".sha256; | 14 local sha256_hash = require "util.hashes".sha256; |
15 local nameprep = require "util.encodings".stringprep.nameprep; | 15 local nameprep = require "util.encodings".stringprep.nameprep; |
16 local uuid_gen = require"util.uuid".generate; | |
16 | 17 |
17 local xmlns_stream = "http://etherx.jabber.org/streams"; | 18 local xmlns_stream = "http://etherx.jabber.org/streams"; |
18 | 19 |
19 local dialback_requests = setmetatable({}, { __mode = 'v' }); | 20 local dialback_requests = setmetatable({}, { __mode = 'v' }); |
20 | 21 |
22 local dialback_secret = module.host .. (module:get_option_string("dialback_secret") or uuid_gen()); | |
23 | |
21 function generate_dialback(id, to, from) | 24 function generate_dialback(id, to, from) |
22 return sha256_hash(id..to..from..hosts[from].dialback_secret, true); | 25 return sha256_hash(id..to..dialback_secret, true); |
23 end | 26 end |
24 | 27 |
25 function initiate_dialback(session) | 28 function initiate_dialback(session) |
26 -- generate dialback key | 29 -- generate dialback key |
27 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); | 30 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); |