Annotate

mod_auth_custom_http/mod_auth_custom_http.lua @ 1045:76668bb122c2

mod_auth_custom_http: No need for nodeprep in Prosody 0.9.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 03 Jun 2013 07:57:12 -0400
parent 1044:fcb9bf7ac107
child 1046:b9d47487d550
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1043
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1 -- Prosody IM
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 -- Copyright (C) 2008-2010 Waqas Hussain
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 --
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 -- This project is MIT/X11 licensed. Please see the
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 -- COPYING file in the source package for more information.
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 --
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 local log = require "util.logger".init("auth_custom_http");
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 local new_sasl = require "util.sasl".new;
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local nodeprep = require "util.encodings".stringprep.nodeprep;
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 local provider = {};
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 function provider.test_password(username, password)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 return nil, "Not supported"
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 function provider.get_password(username)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 return nil, "Not supported"
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 function provider.set_password(username, password)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 return nil, "Not supported"
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 function provider.user_exists(username)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27 return true;
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 function provider.create_user(username, password)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 return nil, "Not supported"
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34 function provider.delete_user(username)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
35 return nil, "Not supported"
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
36 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
37
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
38 function provider.get_sasl_handler()
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
39 local getpass_authentication_profile = {
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
40 plain_test = function(sasl, username, password, realm)
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
41 local postdata = require "util.json".encode({ username = username, password = password });
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
42 local result = require "socket.http".request("http://example.com/path", postdata);
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
43 return result == "true", true;
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
44 end,
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
45 };
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
46 return new_sasl(module.host, getpass_authentication_profile);
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
47 end
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
48
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
49
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
50 module:provides("auth", provider);
809f7d46ad5c mod_auth_custom_http: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
51