Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Add pre and post validation for users that want to use their own public keys
Andrei Bora92e6cf76183d
diff --git a/resources/prosody-plugins/mod_auth_token.lua b/resources/prosody-plugins/mod_auth_token.luaindex 76db977899..5f3b9f57af 100644--- a/resources/prosody-plugins/mod_auth_token.lua+++ b/resources/prosody-plugins/mod_auth_token.lua@@ -74,18 +74,28 @@ function provider.delete_user(username)return nil;end+local function validate_result(session, res, error, reason)+ if res == false then+ log("warn",+ "Error verifying token err:%s, reason:%s", error, reason);+ session.auth_token = nil;+ return res, error, reason;+ end+end+function provider.get_sasl_handler(session)local function get_username_from_token(self, message)- local res, error, reason = token_util:process_and_verify_token(session);- if (res == false) then- log("warn",- "Error verifying token err:%s, reason:%s", error, reason);- session.auth_token = nil;- return res, error, reason;+ -- retrieve custom public key from server and save it on the session+ local event_result = prosody.events.fire_event("pre-jitsi-authentication-fetch-key", session);+ if event_result ~= nil then+ validate_result(session,event_result.res, event_result.error, event_result.reason)end+ local res, error, reason = token_util:process_and_verify_token(session);+ validate_result(session, res, error, reason);+local customUsername= prosody.events.fire_event("pre-jitsi-authentication", session);@@ -102,6 +112,11 @@ function provider.get_sasl_handler(session)self.username = message;end+ local event_result = prosody.events.fire_event("post-jitsi-authentication", session);+ if event_result ~= nil then+ validate_result(session,event_result.res, event_result.error, event_result.reason)+ end+return res;enddiff --git a/resources/prosody-plugins/token/util.lib.lua b/resources/prosody-plugins/token/util.lib.luaindex 902a7808fd..6c19245d7c 100644--- a/resources/prosody-plugins/token/util.lib.lua+++ b/resources/prosody-plugins/token/util.lib.lua@@ -301,7 +301,10 @@ function Util:process_and_verify_token(session, acceptedIssuers)endlocal pubKey;- if self.asapKeyServer and session.auth_token ~= nil then+ if session.public_key then+ module:log("debug","Public key was found on the session");+ pubKey = session.public_key;+ elseif self.asapKeyServer and session.auth_token ~= nil thenlocal dotFirst = session.auth_token:find("%.");if not dotFirst then return nil, "Invalid token" endlocal header, err = json_safe.decode(basexx.from_url64(session.auth_token:sub(1,dotFirst-1)));