plugins/mod_saslauth.lua

changeset 1721
1dcfb2c64302
parent 1523
841d61be198f
child 1725
fb3137652ea6
child 1846
fdb43fc1bafc
equal deleted inserted replaced
1720:c34409a5fdee 1721:1dcfb2c64302
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 15 local nodeprep = require "util.encodings".stringprep.nodeprep;
16 local datamanager_load = require "util.datamanager".load; 16 local datamanager_load = require "util.datamanager".load;
17 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; 17 local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
18 local t_concat, t_insert = table.concat, table.insert; 18 local t_concat, t_insert = table.concat, table.insert;
19 local tostring = tostring; 19 local tostring = tostring;
20 local jid_split = require "util.jid".split 20 local jid_split = require "util.jid".split
63 session:reset_stream(); 63 session:reset_stream();
64 end 64 end
65 end 65 end
66 66
67 local function password_callback(node, hostname, realm, mechanism, decoder) 67 local function password_callback(node, hostname, realm, mechanism, decoder)
68 local func = function(x) return x; end;
69 local node = nodeprep(node);
70 if not node then
71 return func, nil;
72 end
68 local password = (datamanager_load(node, hostname, "accounts") or {}).password; -- FIXME handle hashed passwords 73 local password = (datamanager_load(node, hostname, "accounts") or {}).password; -- FIXME handle hashed passwords
69 local func = function(x) return x; end;
70 if password then 74 if password then
71 if mechanism == "PLAIN" then 75 if mechanism == "PLAIN" then
72 return func, password; 76 return func, password;
73 elseif mechanism == "DIGEST-MD5" then 77 elseif mechanism == "DIGEST-MD5" then
74 if decoder then node, realm, password = decoder(node), decoder(realm), decoder(password); end 78 if decoder then node, realm, password = decoder(node), decoder(realm), decoder(password); end

mercurial