소스 검색

feature: jibri queue authorization header handler

master
Aaron van Meerten 5 년 전
부모
커밋
4289b23135
1개의 변경된 파일21개의 추가작업 그리고 3개의 파일을 삭제
  1. 21
    3
      resources/prosody-plugins/mod_jibri_queue_component.lua

+ 21
- 3
resources/prosody-plugins/mod_jibri_queue_component.lua 파일 보기

@@ -86,6 +86,9 @@ end
86 86
 
87 87
 log("info", "Starting jibri queue handling for %s", muc_component_host);
88 88
 
89
+local external_api_url = module:get_option_string("external_api_url",tostring(parentHostName));
90
+module:log("info", "External advertised API URL", external_api_url);
91
+
89 92
 -- Read ASAP key once on module startup
90 93
 local f = io.open(ASAPKeyPath, "r");
91 94
 if f then
@@ -174,6 +177,7 @@ local function sendEvent(type,room_address,participant)
174 177
         ["room_param"] = room_param,
175 178
         ["event_type"] = type,
176 179
         ["participant"] = participant,
180
+        ["external_api_url"] = external_api_url.."/jibriqueue/update",
177 181
     }
178 182
     module:log("debug","Sending event %s",inspect(out_event));
179 183
 
@@ -351,11 +355,25 @@ function handle_update_jibri_queue(event)
351 355
         return { status_code = 400; };
352 356
     end
353 357
 
358
+    local body = json.decode(event.request.body);
354 359
     local params = parse(event.request.url.query);
355
-    local user_jid = params["user"];
356
-    local roomAddress = params["room"];
357 360
 
358
-    if not verify_token(params["token"], roomAddress, {}) then
361
+    local token = params["token"];
362
+    if not token then
363
+        token = event.request.headers["authorization"];
364
+        local prefixStart, prefixEnd = token:find("Bearer ");
365
+        if prefixStart ~= 1 then
366
+            module:log("error", "Invalid authorization header format. The header must start with the string 'Bearer '");
367
+            return 403
368
+        end
369
+        token = token:sub(prefixEnd + 1);
370
+    end
371
+    
372
+    local user_jid = body["participant"];
373
+    local roomAddress = body["conference"];
374
+    local userJWT = body["token"];
375
+
376
+    if not verify_token(token, roomAddress, {}) then
359 377
         return { status_code = 403; };
360 378
     end
361 379
 

Loading…
취소
저장