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
fix(prosody): keep the token claims when a session resumes on an anonymous host
damenchobe7df408e911
diff --git a/resources/prosody-plugins/mod_auth_token.lua b/resources/prosody-plugins/mod_auth_token.luaindex 08f22de983..0b62a75eb3 100644--- a/resources/prosody-plugins/mod_auth_token.lua+++ b/resources/prosody-plugins/mod_auth_token.lua@@ -244,16 +244,21 @@ module:hook_global('c2s-session-updated', function (event)return;end- -- copy all the custom fields we set in the session- session.auth_token = from_session.auth_token;- session.jitsi_meet_context_user = from_session.jitsi_meet_context_user;- session.jitsi_meet_context_group = from_session.jitsi_meet_context_group;- session.jitsi_meet_context_features = from_session.jitsi_meet_context_features;- session.jitsi_meet_context_room = from_session.jitsi_meet_context_room;- session.jitsi_meet_room = from_session.jitsi_meet_room;- session.jitsi_meet_str_tenant = from_session.jitsi_meet_str_tenant;- session.jitsi_meet_domain = from_session.jitsi_meet_domain;- session.jitsi_meet_tenant_mismatch = from_session.jitsi_meet_tenant_mismatch;+ -- copy all the custom fields we set in the session, but only when from_session carries+ -- them: a connection resumed on an anonymous host holds just the raw token (put there+ -- by mod_jitsi_session) and no claims, so copying would discard the ones the+ -- verification above has just put on the session.+ if from_session._jitsi_auth_done then+ session.auth_token = from_session.auth_token;+ session.jitsi_meet_context_user = from_session.jitsi_meet_context_user;+ session.jitsi_meet_context_group = from_session.jitsi_meet_context_group;+ session.jitsi_meet_context_features = from_session.jitsi_meet_context_features;+ session.jitsi_meet_context_room = from_session.jitsi_meet_context_room;+ session.jitsi_meet_room = from_session.jitsi_meet_room;+ session.jitsi_meet_str_tenant = from_session.jitsi_meet_str_tenant;+ session.jitsi_meet_domain = from_session.jitsi_meet_domain;+ session.jitsi_meet_tenant_mismatch = from_session.jitsi_meet_tenant_mismatch;+ endif reverify_rooms thenlocal result = prosody.events.fire_event('jitsi-verify-session-rooms', { session = session; });diff --git a/tests/prosody/mod_auth_token_spec.js b/tests/prosody/mod_auth_token_spec.jsindex 9a1b57df11..dacd8fa2b3 100644--- a/tests/prosody/mod_auth_token_spec.js+++ b/tests/prosody/mod_auth_token_spec.js@@ -445,4 +445,34 @@ describe('mod_auth_token (claims on XEP-0198 resumption)', () => {await prosodyShell(`module:load("token_verification", "${CONFERENCE}")`);}});++ it('keeps the claims it verified when the session resumes on an anonymous host', async () => {+ // Inline authentication: a guest connects anonymously, logs in without+ // reloading and resumes the same session presenting a token. The+ // anonymous host has no token auth of its own, so the resuming+ // connection carries the raw token and none of the claims, and the ones+ // verified on this event are the only ones the session ever gets.++ // The HS256 host would verify the RS256 token against its own secret and+ // close the session; production has a single token VirtualHost.+ await prosodyShell('module:unload("auth_token", "hs256.localhost")');++ try {+ const guest = await createXmppClient({ domain: 'jitsi-anonymous.localhost' });++ clients.push(guest);++ const reconnected = guest.waitForReconnect();++ guest.dropConnection({ token: tokenFor(`resume-anon-${++roomCounter}`) });+ await reconnected;++ const session = await getSessionLive(guest.jid);++ assert.equal(session.jitsi_meet_context_user?.id, 'user-a',+ 'the user claim of the token presented on resume must be kept');+ } finally {+ await prosodyShell('module:load("auth_token", "hs256.localhost")');+ }+ });});