Software /
code /
prosody
Comparison
plugins/mod_saslauth.lua @ 565:3a49d85cafbc
Backed out changeset 099d8a102deb (committed too much)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 19:49:16 +0000 |
parent | 563:099d8a102deb |
child | 595:08ed4fa2f89d |
comparison
equal
deleted
inserted
replaced
563:099d8a102deb | 565:3a49d85cafbc |
---|---|
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 | 24 local jid |
25 local base64 = require "util.encodings".base64; | 25 local base64 = require "util.encodings".base64; |
26 | |
27 local gettime = require "socket".gettime; | |
28 | 26 |
29 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; | 27 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
30 local t_concat, t_insert = table.concat, table.insert; | 28 local t_concat, t_insert = table.concat, table.insert; |
31 local tostring = tostring; | 29 local tostring = tostring; |
32 local jid_split = require "util.jid".split | 30 local jid_split = require "util.jid".split |
64 session.sasl_handler = nil; | 62 session.sasl_handler = nil; |
65 session:reset_stream(); | 63 session:reset_stream(); |
66 end | 64 end |
67 end | 65 end |
68 | 66 |
69 local function password_callback(node, host, mechanism) | 67 local function password_callback(node, host, mechanism, raw_host) |
70 local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords | 68 local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords |
71 local func = function(x) return x; end; | 69 local func = function(x) return x; end; |
72 if password then | 70 if password then |
73 if mechanism == "PLAIN" then | 71 if mechanism == "PLAIN" then |
74 return func, password; | 72 return func, password; |
75 elseif mechanism == "DIGEST-MD5" then | 73 elseif mechanism == "DIGEST-MD5" then |
76 return func, md5(node..":"..host..":"..password); | 74 return func, md5(node..":"..raw_host..":"..password); |
77 end | 75 end |
78 end | 76 end |
79 return func, nil; | 77 return func, nil; |
80 end | 78 end |
81 | 79 |
142 else | 140 else |
143 session.send(st.reply(stanza) | 141 session.send(st.reply(stanza) |
144 :tag("bind", { xmlns = xmlns_bind}) | 142 :tag("bind", { xmlns = xmlns_bind}) |
145 :tag("jid"):text(session.full_jid)); | 143 :tag("jid"):text(session.full_jid)); |
146 end | 144 end |
147 | |
148 session.log("******", "Connection took "..tostring(session.conntimetotal).." seconds"); | |
149 end); | 145 end); |
150 | 146 |
151 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", | 147 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", |
152 function (session, stanza) | 148 function (session, stanza) |
153 log("debug", "Client tried to bind to a resource"); | 149 log("debug", "Client tried to bind to a resource"); |