# HG changeset patch # User Waqas Hussain # Date 1370272190 14400 # Node ID b9d47487d5509903aa4079234625657e54fe9991 # Parent 76668bb122c2a252b44c0cf787c6db7d6c97959b mod_auth_custom_http: Organize imports, and make the URL a config option. diff -r 76668bb122c2 -r b9d47487d550 mod_auth_custom_http/mod_auth_custom_http.lua --- a/mod_auth_custom_http/mod_auth_custom_http.lua Mon Jun 03 07:57:12 2013 -0400 +++ b/mod_auth_custom_http/mod_auth_custom_http.lua Mon Jun 03 11:09:50 2013 -0400 @@ -5,9 +5,13 @@ -- COPYING file in the source package for more information. -- -local log = require "util.logger".init("auth_custom_http"); local new_sasl = require "util.sasl".new; -local nodeprep = require "util.encodings".stringprep.nodeprep; +local json_encode = require "util.json"; +local http = require "socket.http"; + +local options = module:get_option("auth_custom_http"); +local post_url = options and options.post_url; +assert(post_url, "No HTTP POST URL provided"); local provider = {}; @@ -38,8 +42,8 @@ function provider.get_sasl_handler() local getpass_authentication_profile = { plain_test = function(sasl, username, password, realm) - local postdata = require "util.json".encode({ username = username, password = password }); - local result = require "socket.http".request("http://example.com/path", postdata); + local postdata = json_encode({ username = username, password = password }); + local result = http.request(post_url, postdata); return result == "true", true; end, };