浏览代码

call module that checks the jwt against the access service

master
alexbratu92 3 年前
父节点
当前提交
0c187f180f
共有 2 个文件被更改,包括 16 次插入4 次删除
  1. 6
    0
      resources/prosody-plugins/mod_auth_token.lua
  2. 10
    4
      resources/prosody-plugins/util.lib.lua

+ 6
- 0
resources/prosody-plugins/mod_auth_token.lua 查看文件

@@ -85,6 +85,12 @@ function provider.get_sasl_handler(session)
85 85
             return res, error, reason;
86 86
         end
87 87
 
88
+        local shouldAllow = prosody.events.fire_event("jitsi-access-ban-check", session);
89
+        if shouldAllow == false then
90
+            log("warn", "user is banned")
91
+            return false, "not-allowed", "user is banned";
92
+        end
93
+
88 94
         local customUsername
89 95
             = prosody.events.fire_event("pre-jitsi-authentication", session);
90 96
 

+ 10
- 4
resources/prosody-plugins/util.lib.lua 查看文件

@@ -267,13 +267,19 @@ end
267 267
 --- retry @param retry number of times
268 268
 -- @param url endpoint to be called
269 269
 -- @param retry nr of retries, if retry is
270
+-- @param auth_token value to be passed as auth Bearer 
270 271
 -- nil there will be no retries
271 272
 -- @returns result of the http call or nil if
272 273
 -- the external call failed after the last retry
273
-function http_get_with_retry(url, retry)
274
+function http_get_with_retry(url, retry, auth_token)
274 275
     local content, code;
275 276
     local timeout_occurred;
276 277
     local wait, done = async.waiter();
278
+    local request_headers = http_headers or {}
279
+    if auth_token ~= nil then
280
+        request_headers['Authorization'] = 'Bearer ' .. auth_token
281
+    end
282
+
277 283
     local function cb(content_, code_, response_, request_)
278 284
         if timeout_occurred == nil then
279 285
             code = code_;
@@ -281,7 +287,7 @@ function http_get_with_retry(url, retry)
281 287
                 module:log("debug", "External call was successful, content %s", content_);
282 288
                 content = content_
283 289
             else
284
-                module:log("warn", "Error on public key request: Code %s, Content %s",
290
+                module:log("warn", "Error on GET request: Code %s, Content %s",
285 291
                     code_, content_);
286 292
             end
287 293
             done();
@@ -292,7 +298,7 @@ function http_get_with_retry(url, retry)
292 298
 
293 299
     local function call_http()
294 300
         return http.request(url, {
295
-            headers = http_headers or {},
301
+            headers = request_headers,
296 302
             method = "GET"
297 303
         }, cb);
298 304
     end
@@ -326,7 +332,7 @@ function http_get_with_retry(url, retry)
326 332
     timer.add_task(http_timeout, cancel);
327 333
     wait();
328 334
 
329
-    return content;
335
+    return content, code;
330 336
 end
331 337
 
332 338
 -- Checks whether there is status in the <x node

正在加载...
取消
保存