Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(conference): Process unauthenticated access disabled error. (#16465)
Дамян Минковe6fbeb945827
diff --git a/lang/main.json b/lang/main.jsonindex 03e64224d7..4435980231 100644--- a/lang/main.json+++ b/lang/main.json@@ -522,6 +522,7 @@"tokenAuthFailedWithReasons": "Sorry, you're not allowed to join this call. Possible reasons: {{reason}}","tokenAuthUnsupported": "Token URL is not supported.","transcribing": "Transcribing",+ "unauthenticatedAccessDisabled": "This call requires authentication. Please login in order to proceed.","unlockRoom": "Remove meeting $t(lockRoomPassword)","user": "User","userIdentifier": "User identifier",@@ -1436,8 +1437,8 @@"linkToSalesforce": "Link to Salesforce","lobbyButtonDisable": "Disable lobby mode","lobbyButtonEnable": "Enable lobby mode",- "login": "Log-in",- "logout": "Log-out",+ "login": "Log In",+ "logout": "Log Out","love": "Heart","lowerYourHand": "Lower your hand","moreActions": "More actions",diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.tsindex ea9cd91aef..6a32ff4588 100644--- a/react/features/base/conference/middleware.any.ts+++ b/react/features/base/conference/middleware.any.ts@@ -13,6 +13,7 @@ import {import { sendAnalytics } from '../../analytics/functions';import { reloadNow } from '../../app/actions';import { IStore } from '../../app/types';+import { login } from '../../authentication/actions.any';import { removeLobbyChatParticipant } from '../../chat/actions.any';import { openDisplayNamePrompt } from '../../display-name/actions';import { isVpaasMeeting } from '../../jaas/functions';@@ -251,7 +252,7 @@ function _conferenceFailed({ dispatch, getState }: IStore, next: Function, actiocase JitsiConferenceErrors.NOT_ALLOWED_ERROR: {const [ type, msg ] = error.params;- let descriptionKey;+ let descriptionKey, customActionNameKey, customActionHandler;let titleKey = 'dialog.tokenAuthFailed';if (type === JitsiConferenceErrors.AUTH_ERROR_TYPES.NO_MAIN_PARTICIPANTS) {@@ -263,9 +264,15 @@ function _conferenceFailed({ dispatch, getState }: IStore, next: Function, actiodescriptionKey = 'visitors.notification.notAllowedPromotion';} else if (type === JitsiConferenceErrors.AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION) {descriptionKey = 'dialog.errorRoomCreationRestriction';+ } else if (type === JitsiConferenceErrors.AUTH_ERROR_TYPES.ROOM_UNAUTHENTICATED_ACCESS_DISABLED) {+ titleKey = 'dialog.unauthenticatedAccessDisabled';+ customActionNameKey = [ 'toolbar.login' ];+ customActionHandler = [ () => dispatch(login()) ];}dispatch(showErrorNotification({+ customActionNameKey,+ customActionHandler,descriptionKey,hideErrorSupportLink: true,titleKeydiff --git a/react/features/notifications/components/web/Notification.tsx b/react/features/notifications/components/web/Notification.tsxindex 3535cdc51a..54ee3bdc7d 100644--- a/react/features/notifications/components/web/Notification.tsx+++ b/react/features/notifications/components/web/Notification.tsx@@ -244,6 +244,27 @@ const Notification = ({window.open(supportUrl, '_blank', 'noopener');}, [ supportUrl ]);+ const processCustomActions+ = (key?: string[], handler?: Function[], type?: string[]): {+ content: string; onClick: () => void; testId?: string; type?: string; }[] => {+ if (key?.length && handler?.length) {+ return key.map((customAction: string, customActionIndex: number) => {+ return {+ content: t(customAction),+ onClick: () => {+ if (handler?.[customActionIndex]()) {+ onDismiss();+ }+ },+ type: type?.[customActionIndex],+ testId: customAction+ };+ });+ }++ return [];+ };+const mapAppearanceToButtons = useCallback((): {content: string; onClick: () => void; testId?: string; type?: string; }[] => {switch (appearance) {@@ -262,7 +283,7 @@ const Notification = ({});}- return buttons;+ return processCustomActions(customActionNameKey, customActionHandler, customActionType).concat(buttons);}case NOTIFICATION_TYPE.WARNING:return [@@ -273,22 +294,7 @@ const Notification = ({];default:- if (customActionNameKey?.length && customActionHandler?.length) {- return customActionNameKey.map((customAction: string, customActionIndex: number) => {- return {- content: t(customAction),- onClick: () => {- if (customActionHandler?.[customActionIndex]()) {- onDismiss();- }- },- type: customActionType?.[customActionIndex],- testId: customAction- };- });- }-- return [];+ return processCustomActions(customActionNameKey, customActionHandler, customActionType);}}, [ appearance, onDismiss, customActionHandler, customActionNameKey, hideErrorSupportLink, supportUrl ]);diff --git a/resources/prosody-plugins/README.md b/resources/prosody-plugins/README.mdindex f9feed9664..f6ff75f310 100644--- a/resources/prosody-plugins/README.md+++ b/resources/prosody-plugins/README.md@@ -1,5 +1,6 @@#### room._data fields- allModerators - If is set to true, all authenticated participants are moderators. You need a custom module to set participants as moderators based on the field.+- allowUnauthenticatedAccess - Option that works only with tenants. When it is false only jwt authenticated participants(visitors) are allowed in the meeting and their token(or sub claim for jaas) should match the one in the room. Default value when missing is true.- av_can_unmute - Default value is missing/true. If set to false, when the first moderator joining the room we enable AV moderation and disable the ability for participants to unmute themselves.- av_first_moderator_joined - When av_can_unmute is set to false, this flag is used to indicate that the first moderator has joined the room and AV moderation is enabled.- breakout_rooms - A table containing breakout rooms created in the main room. The keys are the JIDs of the breakout rooms, and the values are their subjects.diff --git a/resources/prosody-plugins/mod_fmuc.lua b/resources/prosody-plugins/mod_fmuc.luaindex 248ac78a82..e9344bce5a 100644--- a/resources/prosody-plugins/mod_fmuc.lua+++ b/resources/prosody-plugins/mod_fmuc.lua@@ -698,6 +698,10 @@ local function iq_from_main_handler(event)local createdTimestamp = node.attr.createdTimestamp;room.created_timestamp = createdTimestamp and tonumber(createdTimestamp) or nil;+ if node.attr.allowUnauthenticatedAccess then+ room._data.allowUnauthenticatedAccess = node.attr.allowUnauthenticatedAccess == 'true';+ end+if node.attr.lobby == 'true' thenroom._main_room_lobby_enabled = true;elseif node.attr.lobby == 'false' thendiff --git a/resources/prosody-plugins/mod_token_verification.lua b/resources/prosody-plugins/mod_token_verification.luaindex a4b979be04..0b4a7aa8fa 100644--- a/resources/prosody-plugins/mod_token_verification.lua+++ b/resources/prosody-plugins/mod_token_verification.lua@@ -76,12 +76,21 @@ local function verify_user(session, stanza)endif DEBUG then module:log("debug", "Will verify token for user: %s, room: %s ", user_jid, stanza.attr.to); end- if not token_util:verify_room(session, stanza.attr.to) then- module:log("error", "Token %s not allowed to join: %s",- tostring(session.auth_token), tostring(stanza.attr.to));- session.send(- st.error_reply(- stanza, "cancel", "not-allowed", "Room and token mismatched"));+ local res, err, reason = token_util:verify_room(session, stanza.attr.to);+ if not res then+ if not err and not reason then+ reason = 'Room and token mismatched';+ end++ module:log('error', 'Token %s not allowed to join: %s err: %s reason: %s',+ tostring(session.auth_token), tostring(stanza.attr.to), err, reason);++ local response = st.error_reply(stanza, 'cancel', 'not-allowed', reason);+ if err then+ response:tag(err, { xmlns = 'http://jitsi.org/jitmeet' });+ end++ session.send(response);return false; -- we need to just return non nilendif DEBUG then module:log("debug", "allowed: %s to enter/create room: %s", user_jid, stanza.attr.to); enddiff --git a/resources/prosody-plugins/mod_visitors.lua b/resources/prosody-plugins/mod_visitors.luaindex 4d37207f4a..cc84ccbcf6 100644--- a/resources/prosody-plugins/mod_visitors.lua+++ b/resources/prosody-plugins/mod_visitors.lua@@ -70,7 +70,8 @@ local function send_visitors_iq(conference_service, room, type)password = type ~= 'disconnect' and room:get_password() or '',lobby = room._data.lobbyroom and 'true' or 'false',meetingId = room._data.meetingId,- createdTimestamp = room.created_timestamp and tostring(room.created_timestamp) or nil+ createdTimestamp = room.created_timestamp and tostring(room.created_timestamp) or nil,+ allowUnauthenticatedAccess = room._data.allowUnauthenticatedAccess ~= nil and tostring(room._data.allowUnauthenticatedAccess) or nil});if type == 'update' thendiff --git a/resources/prosody-plugins/token/util.lib.lua b/resources/prosody-plugins/token/util.lib.luaindex c473830ef1..6b7f78b3f4 100644--- a/resources/prosody-plugins/token/util.lib.lua+++ b/resources/prosody-plugins/token/util.lib.lua@@ -15,6 +15,7 @@ local http_get_with_retry = main_util.http_get_with_retry;local extract_subdomain = main_util.extract_subdomain;local starts_with = main_util.starts_with;local table_shallow_copy = main_util.table_shallow_copy;+local get_room_from_jid = main_util.get_room_from_jid;local cjson_safe = require 'cjson.safe'local timer = require "util.timer";local async = require "util.async";@@ -374,11 +375,6 @@ end-- it and returns false in case verification was processed-- and was not successfulfunction Util:verify_room(session, room_address)- if self.allowEmptyToken and session.auth_token == nil then- --module:log("debug", "Skipped room token verification - empty tokens are allowed");- return true;- end--- extract room name using all chars, except the not allowed oneslocal room,_,_ = jid.split(room_address);if room == nil then@@ -386,6 +382,18 @@ function Util:verify_room(session, room_address)"Unable to get name of the MUC room ? to: %s", room_address);return true;end+ local room_instance = get_room_from_jid(jid.join(room, self.muc_domain));+ if not room_instance then+ module:log('info', 'Room does not exists:%s %s', room, debug.traceback());+ return false;+ end++ if self.allowEmptyToken and session.auth_token == nil then+ if room_instance._data.allowUnauthenticatedAccess == false then+ return false, 'authentication-required', 'Authentication required';+ end+ return true;+ endlocal auth_room = session.jitsi_meet_room;if auth_room then@@ -453,11 +461,16 @@ function Util:verify_room(session, room_address)if session.jitsi_meet_str_tenantand string.lower(session.jitsi_meet_str_tenant) ~= session.jitsi_web_query_prefix then+ session.jitsi_meet_tenant_mismatch = true;++ if room_instance._data.allowUnauthenticatedAccess == false then+ return false;+ end+module:log('warn', 'Tenant differs for user:%s group:%s url_tenant:%s token_tenant:%s',session.jitsi_meet_context_user and session.jitsi_meet_context_user.id or '',session.jitsi_meet_context_group,session.jitsi_web_query_prefix, session.jitsi_meet_str_tenant);- session.jitsi_meet_tenant_mismatch = true;endlocal auth_domain = string.lower(session.jitsi_meet_domain);