Mercurial > prosody-hg
comparison plugins/mod_saslauth.lua @ 357:17bcecb06420
Use a stanza for c2s stream features instead of an array of strings. Removes a FIXME.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 20 Nov 2008 01:33:25 +0000 |
| parents | a273f3a7b8f8 |
| children | 193f9dd64f17 |
comparison
equal
deleted
inserted
replaced
| 356:8ff322b550a3 | 357:17bcecb06420 |
|---|---|
| 81 | 81 |
| 82 add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler); | 82 add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler); |
| 83 add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler); | 83 add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler); |
| 84 add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler); | 84 add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler); |
| 85 | 85 |
| 86 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; | |
| 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' }; | |
| 86 add_event_hook("stream-features", | 89 add_event_hook("stream-features", |
| 87 function (session, features) | 90 function (session, features) |
| 88 if not session.username then | 91 if not session.username then |
| 89 t_insert(features, "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"); | 92 features:tag("mechanisms", mechanisms_attr); |
| 90 -- 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. |
| 91 t_insert(features, "<mechanism>PLAIN</mechanism>"); | 94 features:tag("mechanism"):text("PLAIN"):up(); |
| 92 t_insert(features, "<mechanism>DIGEST-MD5</mechanism>"); | 95 features:tag("mechanism"):text("DIGEST-MD5"):up(); |
| 93 t_insert(features, "</mechanisms>"); | 96 features:up(); |
| 94 else | 97 else |
| 95 t_insert(features, "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind>"); | 98 features:tag("bind", bind_attr):tag("required"):up():up(); |
| 96 t_insert(features, "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>"); | 99 features:tag("session", xmpp_session_attr):up(); |
| 97 end | 100 end |
| 98 --send [[<register xmlns="http://jabber.org/features/iq-register"/> ]] | |
| 99 end); | 101 end); |
| 100 | 102 |
| 101 add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", | 103 add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", |
| 102 function (session, stanza) | 104 function (session, stanza) |
| 103 log("debug", "Client tried to bind to a resource"); | 105 log("debug", "Client tried to bind to a resource"); |
