Mercurial > prosody-hg
comparison plugins/mod_saslauth.lua @ 1489:4da0131a5ccb
Merged with trunk
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 06 Jul 2009 01:40:43 +0500 |
| parents | 3e04efa8af7e |
| children | 841d61be198f |
comparison
equal
deleted
inserted
replaced
| 1488:0d1aff918303 | 1489:4da0131a5ccb |
|---|---|
| 10 | 10 |
| 11 local st = require "util.stanza"; | 11 local st = require "util.stanza"; |
| 12 local sm_bind_resource = require "core.sessionmanager".bind_resource; | 12 local sm_bind_resource = require "core.sessionmanager".bind_resource; |
| 13 local sm_make_authenticated = require "core.sessionmanager".make_authenticated; | 13 local sm_make_authenticated = require "core.sessionmanager".make_authenticated; |
| 14 local base64 = require "util.encodings".base64; | 14 local base64 = require "util.encodings".base64; |
| 15 local to_unicode = require "util.encodings".idna.to_unicode; | |
| 16 | 15 |
| 17 local datamanager_load = require "util.datamanager".load; | 16 local datamanager_load = require "util.datamanager".load; |
| 18 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; | 17 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
| 19 local t_concat, t_insert = table.concat, table.insert; | 18 local t_concat, t_insert = table.concat, table.insert; |
| 20 local tostring = tostring; | 19 local tostring = tostring; |
| 64 session:reset_stream(); | 63 session:reset_stream(); |
| 65 end | 64 end |
| 66 end | 65 end |
| 67 | 66 |
| 68 local function password_callback(node, hostname, realm, mechanism, decoder) | 67 local function password_callback(node, hostname, realm, mechanism, decoder) |
| 69 local password = (datamanager_load(node, to_unicode(hostname), "accounts") or {}).password; -- FIXME handle hashed passwords | 68 local password = (datamanager_load(node, hostname, "accounts") or {}).password; -- FIXME handle hashed passwords |
| 70 local func = function(x) return x; end; | 69 local func = function(x) return x; end; |
| 71 if password then | 70 if password then |
| 72 if mechanism == "PLAIN" then | 71 if mechanism == "PLAIN" then |
| 73 return func, password; | 72 return func, password; |
| 74 elseif mechanism == "DIGEST-MD5" then | 73 elseif mechanism == "DIGEST-MD5" then |
| 75 if decoder then node, hostname, password = decoder(node), decoder(hostname), decoder(password); end | 74 if decoder then node, realm, password = decoder(node), decoder(realm), decoder(password); end |
| 76 return func, md5(node..":"..realm..":"..password); | 75 return func, md5(node..":"..realm..":"..password); |
| 77 end | 76 end |
| 78 end | 77 end |
| 79 return func, nil; | 78 return func, nil; |
| 80 end | 79 end |
