Comparison

plugins/mod_saslauth.lua @ 1042:a3d77353c18a

mod_*: Fix a load of global accesses
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Apr 2009 21:32:23 +0100
parent 938:663f75dd7b42
child 1071:216f9a9001f1
comparison
equal deleted inserted replaced
1041:07835534d996 1042:a3d77353c18a
8 8
9 9
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 base64 = require "util.encodings".base64; 14 local base64 = require "util.encodings".base64;
14 15
16 local datamanager_load = require "util.datamanager".load;
15 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; 17 local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
16 local t_concat, t_insert = table.concat, table.insert; 18 local t_concat, t_insert = table.concat, table.insert;
17 local tostring = tostring; 19 local tostring = tostring;
18 local jid_split = require "util.jid".split 20 local jid_split = require "util.jid".split
19 local md5 = require "util.hashes".md5; 21 local md5 = require "util.hashes".md5;
47 local function handle_status(session, status) 49 local function handle_status(session, status)
48 if status == "failure" then 50 if status == "failure" then
49 session.sasl_handler = nil; 51 session.sasl_handler = nil;
50 elseif status == "success" then 52 elseif status == "success" then
51 if not session.sasl_handler.username then error("SASL succeeded but we didn't get a username!"); end -- TODO move this to sessionmanager 53 if not session.sasl_handler.username then error("SASL succeeded but we didn't get a username!"); end -- TODO move this to sessionmanager
52 sessionmanager.make_authenticated(session, session.sasl_handler.username); 54 sm_make_authenticated(session, session.sasl_handler.username);
53 session.sasl_handler = nil; 55 session.sasl_handler = nil;
54 session:reset_stream(); 56 session:reset_stream();
55 end 57 end
56 end 58 end
57 59
58 local function password_callback(node, host, mechanism, decoder) 60 local function password_callback(node, host, mechanism, decoder)
59 local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords 61 local password = (datamanager_load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords
60 local func = function(x) return x; end; 62 local func = function(x) return x; end;
61 if password then 63 if password then
62 if mechanism == "PLAIN" then 64 if mechanism == "PLAIN" then
63 return func, password; 65 return func, password;
64 elseif mechanism == "DIGEST-MD5" then 66 elseif mechanism == "DIGEST-MD5" then