Software /
code /
prosody
Comparison
plugins/mod_saslauth.lua @ 438:193f9dd64f17
Bumper commit for the new modulemanager API \o/ Updates all the modules, though some more changes may be in store.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 27 Nov 2008 03:12:12 +0000 |
parent | 357:17bcecb06420 |
child | 447:c0dae734d3bf |
comparison
equal
deleted
inserted
replaced
437:c1a720db2157 | 438:193f9dd64f17 |
---|---|
77 local s = build_reply(status, ret, err_msg); | 77 local s = build_reply(status, ret, err_msg); |
78 log("debug", "sasl reply: "..tostring(s)); | 78 log("debug", "sasl reply: "..tostring(s)); |
79 session.send(s); | 79 session.send(s); |
80 end | 80 end |
81 | 81 |
82 add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler); | 82 module:add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler); |
83 add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler); | 83 module:add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler); |
84 add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler); | 84 module:add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler); |
85 | 85 |
86 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; | 86 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; |
87 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; | 87 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; |
88 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; | 88 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; |
89 add_event_hook("stream-features", | 89 module:add_event_hook("stream-features", |
90 function (session, features) | 90 function (session, features) |
91 if not session.username then | 91 if not session.username then |
92 features:tag("mechanisms", mechanisms_attr); | 92 features:tag("mechanisms", mechanisms_attr); |
93 -- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so. | 93 -- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so. |
94 features:tag("mechanism"):text("PLAIN"):up(); | 94 features:tag("mechanism"):text("PLAIN"):up(); |
98 features:tag("bind", bind_attr):tag("required"):up():up(); | 98 features:tag("bind", bind_attr):tag("required"):up():up(); |
99 features:tag("session", xmpp_session_attr):up(); | 99 features:tag("session", xmpp_session_attr):up(); |
100 end | 100 end |
101 end); | 101 end); |
102 | 102 |
103 add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", | 103 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", |
104 function (session, stanza) | 104 function (session, stanza) |
105 log("debug", "Client tried to bind to a resource"); | 105 log("debug", "Client tried to bind to a resource"); |
106 local resource; | 106 local resource; |
107 if stanza.attr.type == "set" then | 107 if stanza.attr.type == "set" then |
108 local bind = stanza.tags[1]; | 108 local bind = stanza.tags[1]; |
121 :tag("bind", { xmlns = xmlns_bind}) | 121 :tag("bind", { xmlns = xmlns_bind}) |
122 :tag("jid"):text(session.full_jid)); | 122 :tag("jid"):text(session.full_jid)); |
123 end | 123 end |
124 end); | 124 end); |
125 | 125 |
126 add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", | 126 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", |
127 function (session, stanza) | 127 function (session, stanza) |
128 log("debug", "Client tried to bind to a resource"); | 128 log("debug", "Client tried to bind to a resource"); |
129 session.send(st.reply(stanza)); | 129 session.send(st.reply(stanza)); |
130 end); | 130 end); |