Comparison

plugins/mod_saslauth.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 5351:901ed253bbf7
child 5535:0df0afc041d7
comparison
equal deleted inserted replaced
5361:38e7a5fafb28 5362:612467e263af
9 9
10 10
11 local st = require "util.stanza"; 11 local st = require "util.stanza";
12 local sm_bind_resource = require "core.sessionmanager".bind_resource; 12 local sm_bind_resource = require "core.sessionmanager".bind_resource;
13 local sm_make_authenticated = require "core.sessionmanager".make_authenticated; 13 local sm_make_authenticated = require "core.sessionmanager".make_authenticated;
14 local s2s_make_authenticated = require "core.s2smanager".make_authenticated;
15 local base64 = require "util.encodings".base64; 14 local base64 = require "util.encodings".base64;
16 15
17 local cert_verify_identity = require "util.x509".verify_identity; 16 local cert_verify_identity = require "util.x509".verify_identity;
18 17
19 local usermanager_get_sasl_handler = require "core.usermanager".get_sasl_handler; 18 local usermanager_get_sasl_handler = require "core.usermanager".get_sasl_handler;
88 module:log("debug", "SASL EXTERNAL with %s succeeded", session.to_host); 87 module:log("debug", "SASL EXTERNAL with %s succeeded", session.to_host);
89 session.external_auth = "succeeded" 88 session.external_auth = "succeeded"
90 session:reset_stream(); 89 session:reset_stream();
91 session:open_stream(); 90 session:open_stream();
92 91
93 s2s_make_authenticated(session, session.to_host); 92 module:fire_event("s2s-authenticated", { session = session, host = session.to_host });
94 return true; 93 return true;
95 end) 94 end)
96 95
97 module:hook_stanza(xmlns_sasl, "failure", function (session, stanza) 96 module:hook_stanza(xmlns_sasl, "failure", function (session, stanza)
98 if session.type ~= "s2sout_unauthed" or session.external_auth ~= "attempting" then return; end 97 if session.type ~= "s2sout_unauthed" or session.external_auth ~= "attempting" then return; end
185 end 184 end
186 session.sends2s(build_reply("success")) 185 session.sends2s(build_reply("success"))
187 186
188 local domain = text ~= "" and text or session.from_host; 187 local domain = text ~= "" and text or session.from_host;
189 module:log("info", "Accepting SASL EXTERNAL identity from %s", domain); 188 module:log("info", "Accepting SASL EXTERNAL identity from %s", domain);
190 s2s_make_authenticated(session, domain); 189 module:fire_event("s2s-authenticated", { session = session, host = domain });
191 session:reset_stream(); 190 session:reset_stream();
192 return true 191 return true
193 end 192 end
194 193
195 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:auth", function(event) 194 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:auth", function(event)