Software /
code /
prosody
Comparison
plugins/mod_saslauth.lua @ 705:11afa1d88c55
mod_saslauth, mod_tls: minor code cleanup
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 13 Jan 2009 19:37:12 +0500 |
parent | 615:4ae3e81513f3 |
child | 724:8beae443867f |
comparison
equal
deleted
inserted
replaced
704:ef8d0d339172 | 705:11afa1d88c55 |
---|---|
19 | 19 |
20 | 20 |
21 | 21 |
22 local st = require "util.stanza"; | 22 local st = require "util.stanza"; |
23 local sm_bind_resource = require "core.sessionmanager".bind_resource; | 23 local sm_bind_resource = require "core.sessionmanager".bind_resource; |
24 local jid | |
25 local base64 = require "util.encodings".base64; | 24 local base64 = require "util.encodings".base64; |
26 | 25 |
27 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; | 26 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
28 local t_concat, t_insert = table.concat, table.insert; | 27 local t_concat, t_insert = table.concat, table.insert; |
29 local tostring = tostring; | 28 local tostring = tostring; |
78 end | 77 end |
79 end | 78 end |
80 return func, nil; | 79 return func, nil; |
81 end | 80 end |
82 | 81 |
83 function sasl_handler(session, stanza) | 82 local function sasl_handler(session, stanza) |
84 if stanza.name == "auth" then | 83 if stanza.name == "auth" then |
85 -- FIXME ignoring duplicates because ejabberd does | 84 -- FIXME ignoring duplicates because ejabberd does |
86 session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback); | 85 session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback); |
87 elseif not session.sasl_handler then | 86 elseif not session.sasl_handler then |
88 return; -- FIXME ignoring out of order stanzas because ejabberd does | 87 return; -- FIXME ignoring out of order stanzas because ejabberd does |
110 | 109 |
111 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; | 110 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' }; |
112 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; | 111 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; |
113 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; | 112 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; |
114 module:add_event_hook("stream-features", | 113 module:add_event_hook("stream-features", |
115 function (session, features) | 114 function (session, features) |
116 if not session.username then | 115 if not session.username then |
117 features:tag("mechanisms", mechanisms_attr); | 116 features:tag("mechanisms", mechanisms_attr); |
118 -- 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. | 117 -- 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. |
119 features:tag("mechanism"):text("PLAIN"):up(); | 118 features:tag("mechanism"):text("PLAIN"):up(); |
120 features:tag("mechanism"):text("DIGEST-MD5"):up(); | 119 features:tag("mechanism"):text("DIGEST-MD5"):up(); |
121 features:up(); | 120 features:up(); |
122 else | 121 else |
123 features:tag("bind", bind_attr):tag("required"):up():up(); | 122 features:tag("bind", bind_attr):tag("required"):up():up(); |
124 features:tag("session", xmpp_session_attr):up(); | 123 features:tag("session", xmpp_session_attr):up(); |
125 end | 124 end |
126 end); | 125 end); |
127 | 126 |
128 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", | 127 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", |
129 function (session, stanza) | 128 function (session, stanza) |
130 log("debug", "Client tried to bind to a resource"); | 129 log("debug", "Client tried to bind to a resource"); |
131 local resource; | 130 local resource; |