Comparison

mod_auth_custom_http/mod_auth_custom_http.lua @ 1043:809f7d46ad5c

mod_auth_custom_http: Initial commit.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 03 Jun 2013 16:39:40 +0500
child 1044:fcb9bf7ac107
comparison
equal deleted inserted replaced
1042:5fd0860c86cd 1043:809f7d46ad5c
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Waqas Hussain
3 --
4 -- This project is MIT/X11 licensed. Please see the
5 -- COPYING file in the source package for more information.
6 --
7
8 local datamanager = require "util.datamanager";
9 local log = require "util.logger".init("auth_custom_http");
10 local type = type;
11 local error = error;
12 local ipairs = ipairs;
13 local hashes = require "util.hashes";
14 local jid_bare = require "util.jid".bare;
15 local config = require "core.configmanager";
16 local usermanager = require "core.usermanager";
17 local new_sasl = require "util.sasl".new;
18 local nodeprep = require "util.encodings".stringprep.nodeprep;
19 local hosts = hosts;
20
21 local prosody = _G.prosody;
22
23 local provider = {};
24
25 function provider.test_password(username, password)
26 return nil, "Not supported"
27 end
28
29 function provider.get_password(username)
30 return nil, "Not supported"
31 end
32
33 function provider.set_password(username, password)
34 return nil, "Not supported"
35 end
36
37 function provider.user_exists(username)
38 return true;
39 end
40
41 function provider.create_user(username, password)
42 return nil, "Not supported"
43 end
44
45 function provider.delete_user(username)
46 return nil, "Not supported"
47 end
48
49 function provider.get_sasl_handler()
50 local getpass_authentication_profile = {
51 plain_test = function(sasl, username, password, realm)
52 local prepped_username = nodeprep(username);
53 if not prepped_username then
54 log("debug", "NODEprep failed on username: %s", username);
55 return "", nil;
56 end
57 local postdata = require "util.json".encode({ username = username, password = password });
58 local result = require "socket.http".request("http://example.com/path", postdata);
59 return result == "true", true;
60 end,
61 };
62 return new_sasl(module.host, getpass_authentication_profile);
63 end
64
65
66 module:provides("auth", provider);
67