Comparison

plugins/mod_dialback.lua @ 5362:612467e263af

s2smanager, mod_s2s, mod_dialback, mod_saslauth: Move s2smanager.make_authenticated() to mod_s2s, and plugins now signal authentication via the s2s-authenticated event
author Matthew Wild <mwild1@gmail.com>
date Fri, 22 Mar 2013 14:18:23 +0000
parent 5341:760c22c822be
child 5776:bd0ff8ae98a8
child 7103:5c6e78dc1864
comparison
equal deleted inserted replaced
5361:38e7a5fafb28 5362:612467e263af
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8 8
9 local hosts = _G.hosts; 9 local hosts = _G.hosts;
10 local s2s_make_authenticated = require "core.s2smanager".make_authenticated;
11 10
12 local log = module._log; 11 local log = module._log;
13 12
14 local st = require "util.stanza"; 13 local st = require "util.stanza";
15 local sha256_hash = require "util.hashes".sha256; 14 local sha256_hash = require "util.hashes".sha256;
108 local attr = stanza.attr; 107 local attr = stanza.attr;
109 local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")]; 108 local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")];
110 if dialback_verifying and attr.from == origin.to_host then 109 if dialback_verifying and attr.from == origin.to_host then
111 local valid; 110 local valid;
112 if attr.type == "valid" then 111 if attr.type == "valid" then
113 s2s_make_authenticated(dialback_verifying, attr.from); 112 module:fire_event("s2s-authenticated", { session = dialback_verifying, host = attr.from });
114 valid = "valid"; 113 valid = "valid";
115 else 114 else
116 -- Warn the original connection that is was not verified successfully 115 -- Warn the original connection that is was not verified successfully
117 log("warn", "authoritative server for %s denied the key", attr.from or "(unknown)"); 116 log("warn", "authoritative server for %s denied the key", attr.from or "(unknown)");
118 valid = "invalid"; 117 valid = "invalid";
144 -- This isn't right 143 -- This isn't right
145 origin:close("invalid-id"); 144 origin:close("invalid-id");
146 return true; 145 return true;
147 end 146 end
148 if stanza.attr.type == "valid" then 147 if stanza.attr.type == "valid" then
149 s2s_make_authenticated(origin, attr.from); 148 module:fire_event("s2s-authenticated", { session = origin, host = attr.from });
150 else 149 else
151 origin:close("not-authorized", "dialback authentication failed"); 150 origin:close("not-authorized", "dialback authentication failed");
152 end 151 end
153 return true; 152 return true;
154 end 153 end