comparison mod_register_json/mod_register_json.lua @ 851:836e4e110c71

mod_register_json: add option to handle requests only on secure connections.
author Marco Cirillo <maranda@lightwitch.org>
date Tue, 23 Oct 2012 13:32:44 +0000
parents c26652d055b5
children 9c5573b389c0
comparison
equal deleted inserted replaced
850:0900ba54991e 851:836e4e110c71
14 14
15 module:depends("http") 15 module:depends("http")
16 16
17 -- Pick up configuration. 17 -- Pick up configuration.
18 18
19 local secure = module:get_option_boolean("reg_servlet_secure", true) 19 local secure = module:get_option_boolean("reg_servlet_secure", false)
20 local set_realm_name = module:get_option_string("reg_servlet_realm", "Restricted") 20 local set_realm_name = module:get_option_string("reg_servlet_realm", "Restricted")
21 local base_path = module:get_option_string("reg_servlet_base", "/register_account/") 21 local base_path = module:get_option_string("reg_servlet_base", "/register_account/")
22 local throttle_time = module:get_option_number("reg_servlet_ttime", nil) 22 local throttle_time = module:get_option_number("reg_servlet_ttime", nil)
23 local whitelist = module:get_option_set("reg_servlet_wl", {}) 23 local whitelist = module:get_option_set("reg_servlet_wl", {})
24 local blacklist = module:get_option_set("reg_servlet_bl", {}) 24 local blacklist = module:get_option_set("reg_servlet_bl", {})
39 end 39 end
40 40
41 local function handle_req(event) 41 local function handle_req(event)
42 local request = event.request 42 local request = event.request
43 local body = request.body 43 local body = request.body
44 if secure and not request.secure then return nil end
44 45
45 if request.method ~= "POST" then 46 if request.method ~= "POST" then
46 return http_response(event, 405, "Bad method...", {["Allow"] = "POST"}) 47 return http_response(event, 405, "Bad method...", {["Allow"] = "POST"})
47 end 48 end
48 if not request.headers["authorization"] then 49 if not request.headers["authorization"] then