Software /
code /
prosody-modules
Changeset
1046:b9d47487d550
mod_auth_custom_http: Organize imports, and make the URL a config option.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 03 Jun 2013 11:09:50 -0400 |
parents | 1045:76668bb122c2 |
children | 1047:38781835c911 |
files | mod_auth_custom_http/mod_auth_custom_http.lua |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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, };