diff mod_muc_http_auth/mod_muc_http_auth.lua @ 4322:9606e7a63a69

mod_mucc_http_auth: Provide Authorization header setting for deployments behind a login
author Seve Ferrer <seve@delape.net>
date Wed, 06 Jan 2021 20:49:45 +0100
parents caaa40f072da
children 4b3f054666e6
line wrap: on
line diff
--- a/mod_muc_http_auth/mod_muc_http_auth.lua	Wed Jan 06 17:07:16 2021 +0100
+++ b/mod_muc_http_auth/mod_muc_http_auth.lua	Wed Jan 06 20:49:45 2021 +0100
@@ -10,6 +10,12 @@
 local disabled_for = module:get_option_set("muc_http_auth_disabled_for",  nil)
 local insecure = module:get_option("muc_http_auth_insecure", false) --For development purposes
 local authorize_registration = module:get_option("muc_http_auth_authorize_registration", false)
+local authorization_header = module:get_option("muc_http_auth_authorization_header", nil)
+
+local options = {method="GET", insecure=insecure}
+if authorization_header then
+	options.headers = {["Authorization"] = authorization_header};
+end
 
 local verbs = {presence='join', iq='register'};
 
@@ -47,7 +53,7 @@
 	local user_bare_jid = jid_bare(stanza.attr.from);
 	local url = authorization_url .. "?userJID=" .. user_bare_jid .."&mucJID=" .. room.jid;
 
-	local result = wait_for(http.request(url, {method="GET", insecure=insecure}):next(handle_success, handle_error));
+	local result = wait_for(http.request(url, options):next(handle_success, handle_error));
 	local response, err = result.response, result.err;
 
 	local verb = verbs[stanza.name];