# HG changeset patch # User Seve Ferrer # Date 1609962585 -3600 # Node ID 9606e7a63a69fa6122e2b5ab248bd2a71c780573 # Parent 71498f484c22e959834c564fe41467c19a3459c4 mod_mucc_http_auth: Provide Authorization header setting for deployments behind a login diff -r 71498f484c22 -r 9606e7a63a69 mod_muc_http_auth/README.md --- a/mod_muc_http_auth/README.md Wed Jan 06 17:07:16 2021 +0100 +++ b/mod_muc_http_auth/README.md Wed Jan 06 20:49:45 2021 +0100 @@ -45,6 +45,7 @@ |muc_http_auth_enabled_for| List of MUC names (node part) to enable this module for | nil | |muc_http_auth_disabled_for| List of MUC names (node part) to disable this module for | nil | |muc_http_auth_insecure| Disable certificate verification for request. Only intended for development of the external service. | false | +|muc_http_auth_authorization_header| Value of the Authorization header if requested by the external HTTP service. Example: `Basic dXNlcm5hbWU6cGFzc3dvcmQ=`| nil | This module can be enabled/disabled for specific rooms. Only one of the following settings must be set. diff -r 71498f484c22 -r 9606e7a63a69 mod_muc_http_auth/mod_muc_http_auth.lua --- 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];