Bläddra i källkod

Merge pull request #3840 from jitsi/prosody-token-wildcard-subdomain

supports a '*' in the sub claim to allow access to any room
j8
Aaron van Meerten 6 år sedan
förälder
incheckning
3ad99e24cf
Inget konto är kopplat till bidragsgivarens mejladress
1 ändrade filer med 18 tillägg och 2 borttagningar
  1. 18
    2
      resources/prosody-plugins/token/util.lib.lua

+ 18
- 2
resources/prosody-plugins/token/util.lib.lua Visa fil

@@ -357,11 +357,20 @@ function Util:verify_room(session, room_address)
357 357
             room_to_check = room_node;
358 358
         end
359 359
     else
360
+        -- no wildcard, so check room against authorized room in token
360 361
         room_to_check = auth_room;
361 362
     end
362 363
 
363 364
     local auth_domain = session.jitsi_meet_domain;
365
+    local subdomain_to_check;
364 366
     if target_subdomain then
367
+        if auth_domain == '*' then
368
+            -- check for wildcard in JWT claim, allow access if found
369
+            subdomain_to_check = target_subdomain;
370
+        else
371
+            -- no wildcard in JWT claim, so check subdomain against sub in token
372
+            subdomain_to_check = auth_domain;
373
+        end
365 374
         -- from this point we depend on muc_domain_base,
366 375
         -- deny access if option is missing
367 376
         if not self.muc_domain_base then
@@ -370,12 +379,19 @@ function Util:verify_room(session, room_address)
370 379
         end
371 380
 
372 381
         return room_address_to_verify == jid.join(
373
-            "["..auth_domain.."]"..string.lower(room_to_check), self.muc_domain);
382
+            "["..subdomain_to_check.."]"..string.lower(room_to_check), self.muc_domain);
374 383
     else
384
+        if auth_domain == '*' then
385
+            -- check for wildcard in JWT claim, allow access if found
386
+            subdomain_to_check = self.muc_domain;
387
+        else
388
+            -- no wildcard in JWT claim, so check subdomain against sub in token
389
+            subdomain_to_check = self.muc_domain_prefix.."."..auth_domain;
390
+        end
375 391
         -- we do not have a domain part (multidomain is not enabled)
376 392
         -- verify with info from the token
377 393
         return room_address_to_verify == jid.join(
378
-            string.lower(room_to_check), self.muc_domain_prefix.."."..auth_domain);
394
+            string.lower(room_to_check), subdomain_to_check);
379 395
     end
380 396
 end
381 397
 

Laddar…
Avbryt
Spara