Software /
code /
prosody-modules
Comparison
mod_auth_custom_http/mod_auth_custom_http.lua @ 2867:94d8960385aa
mod_auth_custom_http: Fix json.encode impoper reference
author | Senya <senya@kinetiksoft.com> |
---|---|
date | Wed, 31 Jan 2018 22:15:27 +0200 |
parent | 1343:7dbde05b48a9 |
child | 3989:32d7f05e062f |
comparison
equal
deleted
inserted
replaced
2866:276f7af8afd1 | 2867:94d8960385aa |
---|---|
4 -- This project is MIT/X11 licensed. Please see the | 4 -- This project is MIT/X11 licensed. Please see the |
5 -- COPYING file in the source package for more information. | 5 -- COPYING file in the source package for more information. |
6 -- | 6 -- |
7 | 7 |
8 local new_sasl = require "util.sasl".new; | 8 local new_sasl = require "util.sasl".new; |
9 local json_encode = require "util.json"; | 9 local json = require "util.json"; |
10 local http = require "socket.http"; | 10 local http = require "socket.http"; |
11 | 11 |
12 local options = module:get_option("auth_custom_http"); | 12 local options = module:get_option("auth_custom_http"); |
13 local post_url = options and options.post_url; | 13 local post_url = options and options.post_url; |
14 assert(post_url, "No HTTP POST URL provided"); | 14 assert(post_url, "No HTTP POST URL provided"); |
40 end | 40 end |
41 | 41 |
42 function provider.get_sasl_handler() | 42 function provider.get_sasl_handler() |
43 local getpass_authentication_profile = { | 43 local getpass_authentication_profile = { |
44 plain_test = function(sasl, username, password, realm) | 44 plain_test = function(sasl, username, password, realm) |
45 local postdata = json_encode({ username = username, password = password }); | 45 local postdata = json.encode({ username = username, password = password }); |
46 local result = http.request(post_url, postdata); | 46 local result = http.request(post_url, postdata); |
47 return result == "true", true; | 47 return result == "true", true; |
48 end, | 48 end, |
49 }; | 49 }; |
50 return new_sasl(module.host, getpass_authentication_profile); | 50 return new_sasl(module.host, getpass_authentication_profile); |
51 end | 51 end |
52 | 52 |
53 | 53 |
54 module:provides("auth", provider); | 54 module:provides("auth", provider); |
55 |