Comparison

plugins/mod_saslauth.lua @ 7960:9a938b785bc5

mod_saslauth: Switch to hook_tag from hook_stanza which was renamed in 2087d42f1e77
author Kim Alvefur <zash@zash.se>
date Mon, 06 Mar 2017 15:56:12 +0100
parent 7940:e520dc0c3af4
child 7962:4e9b307c30dd
comparison
equal deleted inserted replaced
7959:3941d609ff85 7960:9a938b785bc5
80 log("debug", "sasl reply: %s", tostring(s)); 80 log("debug", "sasl reply: %s", tostring(s));
81 session.send(s); 81 session.send(s);
82 return true; 82 return true;
83 end 83 end
84 84
85 module:hook_stanza(xmlns_sasl, "success", function (session, stanza) 85 module:hook_tag(xmlns_sasl, "success", function (session, stanza)
86 if session.type ~= "s2sout_unauthed" or session.external_auth ~= "attempting" then return; end 86 if session.type ~= "s2sout_unauthed" or session.external_auth ~= "attempting" then return; end
87 module:log("debug", "SASL EXTERNAL with %s succeeded", session.to_host); 87 module:log("debug", "SASL EXTERNAL with %s succeeded", session.to_host);
88 session.external_auth = "succeeded" 88 session.external_auth = "succeeded"
89 session:reset_stream(); 89 session:reset_stream();
90 session:open_stream(session.from_host, session.to_host); 90 session:open_stream(session.from_host, session.to_host);
91 91
92 module:fire_event("s2s-authenticated", { session = session, host = session.to_host }); 92 module:fire_event("s2s-authenticated", { session = session, host = session.to_host });
93 return true; 93 return true;
94 end) 94 end)
95 95
96 module:hook_stanza(xmlns_sasl, "failure", function (session, stanza) 96 module:hook_tag(xmlns_sasl, "failure", function (session, stanza)
97 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
98 98
99 local text = stanza:get_child_text("text"); 99 local text = stanza:get_child_text("text");
100 local condition = "unknown-condition"; 100 local condition = "unknown-condition";
101 for child in stanza:childtags() do 101 for child in stanza:childtags() do
112 session.external_auth = "failed" 112 session.external_auth = "failed"
113 session:close(); 113 session:close();
114 return true; 114 return true;
115 end, 500) 115 end, 500)
116 116
117 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) 117 module:hook_tag("http://etherx.jabber.org/streams", "features", function (session, stanza)
118 if session.type ~= "s2sout_unauthed" or not session.secure then return; end 118 if session.type ~= "s2sout_unauthed" or not session.secure then return; end
119 119
120 local mechanisms = stanza:get_child("mechanisms", xmlns_sasl) 120 local mechanisms = stanza:get_child("mechanisms", xmlns_sasl)
121 if mechanisms then 121 if mechanisms then
122 for mech in mechanisms:childtags() do 122 for mech in mechanisms:childtags() do