call module that checks the jwt against the access service

This commit is contained in:
alexbratu92 2021-10-04 13:19:41 +03:00 committed by Дамян Минков
parent c6d3667211
commit 0c187f180f
2 changed files with 16 additions and 4 deletions

View File

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

View File

@ -267,13 +267,19 @@ end
--- retry @param retry number of times
-- @param url endpoint to be called
-- @param retry nr of retries, if retry is
-- @param auth_token value to be passed as auth Bearer
-- nil there will be no retries
-- @returns result of the http call or nil if
-- the external call failed after the last retry
function http_get_with_retry(url, retry)
function http_get_with_retry(url, retry, auth_token)
local content, code;
local timeout_occurred;
local wait, done = async.waiter();
local request_headers = http_headers or {}
if auth_token ~= nil then
request_headers['Authorization'] = 'Bearer ' .. auth_token
end
local function cb(content_, code_, response_, request_)
if timeout_occurred == nil then
code = code_;
@ -281,7 +287,7 @@ function http_get_with_retry(url, retry)
module:log("debug", "External call was successful, content %s", content_);
content = content_
else
module:log("warn", "Error on public key request: Code %s, Content %s",
module:log("warn", "Error on GET request: Code %s, Content %s",
code_, content_);
end
done();
@ -292,7 +298,7 @@ function http_get_with_retry(url, retry)
local function call_http()
return http.request(url, {
headers = http_headers or {},
headers = request_headers,
method = "GET"
}, cb);
end
@ -326,7 +332,7 @@ function http_get_with_retry(url, retry)
timer.add_task(http_timeout, cancel);
wait();
return content;
return content, code;
end
-- Checks whether there is status in the <x node