Browse Source

call module that checks the jwt against the access service

master
alexbratu92 4 years ago
parent
commit
0c187f180f

+ 6
- 0
resources/prosody-plugins/mod_auth_token.lua View File

85
             return res, error, reason;
85
             return res, error, reason;
86
         end
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
         local customUsername
94
         local customUsername
89
             = prosody.events.fire_event("pre-jitsi-authentication", session);
95
             = prosody.events.fire_event("pre-jitsi-authentication", session);
90
 
96
 

+ 10
- 4
resources/prosody-plugins/util.lib.lua View File

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

Loading…
Cancel
Save