Skip to content

Commit 36ce5a1

Browse files
damenchobgrozev
andauthored
feat(token_verification): Adds more token failure reasons on verify room. (jitsi#16473)
* feat(token_verification): Adds more token failure reasons on verify room. * squash: Update resources/prosody-plugins/token/util.lib.lua Co-authored-by: bgrozev <boris@jitsi.org> --------- Co-authored-by: bgrozev <boris@jitsi.org>
1 parent 23c831e commit 36ce5a1

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

resources/prosody-plugins/token/util.lib.lua

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,13 @@ function Util:verify_room(session, room_address)
378378
-- extract room name using all chars, except the not allowed ones
379379
local room,_,_ = jid.split(room_address);
380380
if room == nil then
381-
log("error",
382-
"Unable to get name of the MUC room ? to: %s", room_address);
383-
return true;
381+
module:log('error', 'Unable to get name of the MUC room ? to: %s', room_address);
382+
return false, 'invalid-room-address', 'Room address is invalid';
384383
end
385384
local room_instance = get_room_from_jid(jid.join(room, self.muc_domain));
386385
if not room_instance then
387386
module:log('info', 'Room does not exists:%s %s', room, debug.traceback());
388-
return false;
387+
return false, 'room-does-not-exist', 'Room does not exist';
389388
end
390389

391390
if self.allowEmptyToken and session.auth_token == nil then
@@ -403,11 +402,11 @@ function Util:verify_room(session, room_address)
403402
module:log('warn', 'session.jitsi_meet_room not string: %s', inspect(auth_room));
404403
end
405404
end
405+
406406
if not self.enableDomainVerification then
407-
-- if auth_room is missing, this means user is anonymous (no token for
408-
-- its domain) we let it through, jicofo is verifying creation domain
407+
-- if auth_room is missing, this means user is anonymous (no token for its domain) we let it through
409408
if auth_room and (room ~= auth_room and not ends_with(room, ']'..auth_room)) and auth_room ~= '*' then
410-
return false;
409+
return false, 'room-mismatch', 'Room does not match the room from token';
411410
end
412411

413412
return true;
@@ -447,15 +446,15 @@ function Util:verify_room(session, room_address)
447446
-- not a regex
448447
room_to_check = auth_room;
449448
end
450-
-- module:log("debug", "room to check: %s", room_to_check)
449+
451450
if not room_to_check then
452451
if not self.requireRoomClaim then
453452
-- if we do not require to have the room claim, and it is missing
454453
-- there is no point of continue and verifying the roomName and the tenant
455454
return true;
456455
end
457456

458-
return false;
457+
return false, 'room-name-does-not-match', 'Room name cannot be matched to the one from token.';
459458
end
460459
end
461460

@@ -487,7 +486,7 @@ function Util:verify_room(session, room_address)
487486
-- deny access if option is missing
488487
if not self.muc_domain_base then
489488
module:log("warn", "No 'muc_domain_base' option set, denying access!");
490-
return false;
489+
return false, 'server-missing-config', 'Misconfiguration of server';
491490
end
492491

493492
return room_address_to_verify == jid.join(

0 commit comments

Comments
 (0)