瀏覽代碼

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
 
86
 
87
 log("info", "Starting jibri queue handling for %s", muc_component_host);
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
 -- Read ASAP key once on module startup
92
 -- Read ASAP key once on module startup
90
 local f = io.open(ASAPKeyPath, "r");
93
 local f = io.open(ASAPKeyPath, "r");
91
 if f then
94
 if f then
174
         ["room_param"] = room_param,
177
         ["room_param"] = room_param,
175
         ["event_type"] = type,
178
         ["event_type"] = type,
176
         ["participant"] = participant,
179
         ["participant"] = participant,
180
+        ["external_api_url"] = external_api_url.."/jibriqueue/update",
177
     }
181
     }
178
     module:log("debug","Sending event %s",inspect(out_event));
182
     module:log("debug","Sending event %s",inspect(out_event));
179
 
183
 
351
         return { status_code = 400; };
355
         return { status_code = 400; };
352
     end
356
     end
353
 
357
 
358
+    local body = json.decode(event.request.body);
354
     local params = parse(event.request.url.query);
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
         return { status_code = 403; };
377
         return { status_code = 403; };
360
     end
378
     end
361
 
379
 

Loading…
取消
儲存