Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(visitors): Whitelist trusted domains when promoting.

damenchob23f3b9e17dd
diff --git a/resources/prosody-plugins/mod_visitors_component.lua b/resources/prosody-plugins/mod_visitors_component.lua
index b95aeb4d3e..293c4e2c9f 100644
--- a/resources/prosody-plugins/mod_visitors_component.lua
+++ b/resources/prosody-plugins/mod_visitors_component.lua
@@ -10,6 +10,7 @@ local get_focus_occupant = util.get_focus_occupant;
local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;
local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
local is_vpaas = util.is_vpaas;
+local is_sip_jibri_join = util.is_sip_jibri_join;
local new_id = require 'util.id'.medium;
local um_is_admin = require 'core.usermanager'.is_admin;
local json = require 'util.json';
@@ -283,7 +284,11 @@ process_host_module(muc_domain_prefix..'.'..muc_domain_base, function(host_modul
-- if visitor mode is started, then you are not allowed to join without request/response exchange of iqs -> deny access
-- check list of allowed jids for the room
host_module:hook('muc-occupant-pre-join', function (event)
- local room, stanza, origin = event.room, event.stanza, event.origin;
+ local room, stanza, occupant, origin = event.room, event.stanza, event.occupant, event.origin;
+
+ if is_healthcheck_room(room.jid) or is_admin(occupant.bare_jid) then
+ return;
+ end
-- visitors were already in the room one way or another they have access
-- skip password challenge
@@ -294,7 +299,10 @@ process_host_module(muc_domain_prefix..'.'..muc_domain_base, function(host_modul
end
-- we skip any checks when auto-allow is enabled
- if auto_allow_promotion then
+ if auto_allow_promotion
+ or ignore_list:contains(jid.host(stanza.attr.from)) -- jibri or other domains to ignore
+ or stanza:get_child('initiator', 'http://jitsi.org/protocol/jigasi')
+ or is_sip_jibri_join(stanza) then
return;
end
diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua
index 928d18a479..bb78a558cf 100644
--- a/resources/prosody-plugins/util.lib.lua
+++ b/resources/prosody-plugins/util.lib.lua
@@ -26,6 +26,9 @@ local target_subdomain_pattern = "^"..escaped_muc_domain_prefix..".([^%.]+)%."..
-- table to store all incoming iqs without roomname in it, like discoinfo to the muc component
local roomless_iqs = {};
+local OUTBOUND_SIP_JIBRI_PREFIX = 'outbound-sip-jibri@';
+local INBOUND_SIP_JIBRI_PREFIX = 'inbound-sip-jibri@';
+
local split_subdomain_cache = cache.new(1000);
local extract_subdomain_cache = cache.new(1000);
local internal_room_jid_cache = cache.new(1000);
@@ -272,6 +275,9 @@ function extract_subdomain(room_node)
end
function starts_with(str, start)
+ if not str then
+ return false;
+ end
return str:sub(1, #start) == start
end
@@ -447,15 +453,57 @@ function is_vpaas(room)
return true;
end
+function get_sip_jibri_email_prefix(email)
+ if not email then
+ return nil;
+ elseif starts_with(email, INBOUND_SIP_JIBRI_PREFIX) then
+ return INBOUND_SIP_JIBRI_PREFIX;
+ elseif starts_with(email, OUTBOUND_SIP_JIBRI_PREFIX) then
+ return OUTBOUND_SIP_JIBRI_PREFIX;
+ else
+ return nil;
+ end
+end
+
+function is_sip_jibri_join(stanza)
+ if not stanza then
+ return false;
+ end
+
+ local features = stanza:get_child('features');
+ local email = stanza:get_child_text('email');
+
+ if not features or not email then
+ return false;
+ end
+
+ for i = 1, #features do
+ local feature = features[i];
+ if feature.attr and feature.attr.var and feature.attr.var == "http://jitsi.org/protocol/jibri" then
+ if get_sip_jibri_email_prefix(email) then
+ module:log("debug", "Occupant with email %s is a sip jibri ", email);
+ return true;
+ end
+ end
+ end
+
+ return false
+end
+
+
return {
+ OUTBOUND_SIP_JIBRI_PREFIX = OUTBOUND_SIP_JIBRI_PREFIX;
+ INBOUND_SIP_JIBRI_PREFIX = INBOUND_SIP_JIBRI_PREFIX;
extract_subdomain = extract_subdomain;
is_feature_allowed = is_feature_allowed;
is_healthcheck_room = is_healthcheck_room;
is_moderated = is_moderated;
+ is_sip_jibri_join = is_sip_jibri_join;
is_vpaas = is_vpaas;
get_focus_occupant = get_focus_occupant;
get_room_from_jid = get_room_from_jid;
get_room_by_name_and_subdomain = get_room_by_name_and_subdomain;
+ get_sip_jibri_email_prefix = get_sip_jibri_email_prefix;
async_handler_wrapper = async_handler_wrapper;
presence_check_status = presence_check_status;
room_jid_match_rewrite = room_jid_match_rewrite;