Browse Source

Lobby required displayname (#7197)

* ref: Rename jitsi_bosh_query_room to jitsi_web_query_room.

This is no longer bosh only and is available for both bosh and websocket sessions.

* feat: Adds feature to disco-info indicating that display name is required.

* feat: Adds option to disable checking whether display name is required.

* ref: Clears auth_token when verification fails.

* squash: Fixing comments.

* squash: Updates to latest lib-jitsi-meet.
master
Дамян Минков 5 years ago
parent
commit
a4ca247056
No account linked to committer's email address

+ 2
- 2
package-lock.json View File

@@ -10724,8 +10724,8 @@
10724 10724
       }
10725 10725
     },
10726 10726
     "lib-jitsi-meet": {
10727
-      "version": "github:jitsi/lib-jitsi-meet#4fec06db7fc59a88021ec0b409eda47f21c42902",
10728
-      "from": "github:jitsi/lib-jitsi-meet#4fec06db7fc59a88021ec0b409eda47f21c42902",
10727
+      "version": "github:jitsi/lib-jitsi-meet#8f9bd254bb3813808e6e1f7974aacc4d1414fcdb",
10728
+      "from": "github:jitsi/lib-jitsi-meet#8f9bd254bb3813808e6e1f7974aacc4d1414fcdb",
10729 10729
       "requires": {
10730 10730
         "@jitsi/sdp-interop": "1.0.3",
10731 10731
         "@jitsi/sdp-simulcast": "0.3.0",

+ 1
- 1
package.json View File

@@ -56,7 +56,7 @@
56 56
     "js-md5": "0.6.1",
57 57
     "js-utils": "github:jitsi/js-utils#cf11996bd866fdb47326c59a5d3bc24be17282d4",
58 58
     "jwt-decode": "2.2.0",
59
-    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#4fec06db7fc59a88021ec0b409eda47f21c42902",
59
+    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#8f9bd254bb3813808e6e1f7974aacc4d1414fcdb",
60 60
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
61 61
     "lodash": "4.17.13",
62 62
     "moment": "2.19.4",

+ 14
- 3
resources/prosody-plugins/mod_auth_token.lua View File

@@ -25,15 +25,25 @@ function init_session(event)
25 25
 
26 26
 	if query ~= nil then
27 27
         local params = formdecode(query);
28
+
29
+        -- The following fields are filled in the session, by extracting them
30
+        -- from the query and no validation is beeing done.
31
+        -- After validating auth_token will be cleaned in case of error and few
32
+        -- other fields will be extracted from the token and set in the session
33
+
28 34
         session.auth_token = query and params.token or nil;
29 35
         -- previd is used together with https://modules.prosody.im/mod_smacks.html
30 36
         -- the param is used to find resumed session and re-use anonymous(random) user id
31 37
         -- (see get_username_from_token)
32 38
         session.previd = query and params.previd or nil;
33 39
 
34
-        -- The room name and optional prefix from the bosh query
35
-        session.jitsi_bosh_query_room = params.room;
36
-        session.jitsi_bosh_query_prefix = params.prefix or "";
40
+        -- The room name and optional prefix from the web query
41
+        session.jitsi_web_query_room = params.room;
42
+        session.jitsi_web_query_prefix = params.prefix or "";
43
+
44
+        -- Deprecated, you should use jitsi_web_query_room and jitsi_web_query_prefix
45
+        session.jitsi_bosh_query_room = session.jitsi_web_query_room;
46
+        session.jitsi_bosh_query_prefix = session.jitsi_web_query_prefix;
37 47
     end
38 48
 end
39 49
 
@@ -72,6 +82,7 @@ function provider.get_sasl_handler(session)
72 82
         if (res == false) then
73 83
             log("warn",
74 84
                 "Error verifying token err:%s, reason:%s", error, reason);
85
+            session.auth_token = nil;
75 86
             return res, error, reason;
76 87
         end
77 88
 

+ 54
- 2
resources/prosody-plugins/mod_muc_lobby_rooms.lua View File

@@ -28,6 +28,9 @@ local jid_bare = require 'util.jid'.bare;
28 28
 local filters = require 'util.filters';
29 29
 local st = require 'util.stanza';
30 30
 local MUC_NS = 'http://jabber.org/protocol/muc';
31
+local DISCO_INFO_NS = 'http://jabber.org/protocol/disco#info';
32
+local DISPLAY_NAME_REQUIRED_FEATURE = 'http://jitsi.org/protocol/lobbyrooms#displayname_required';
33
+local LOBBY_IDENTITY_TYPE = 'lobbyrooms';
31 34
 
32 35
 local is_healthcheck_room = module:require "util".is_healthcheck_room;
33 36
 
@@ -42,7 +45,14 @@ if lobby_muc_component_config == nil then
42 45
     return ;
43 46
 end
44 47
 
45
-local whitelist = module:get_option_set("muc_lobby_whitelist", {});
48
+local whitelist;
49
+local check_display_name_required;
50
+local function load_config()
51
+    whitelist = module:get_option_set("muc_lobby_whitelist", {});
52
+    check_display_name_required
53
+        = module:get_option_boolean("muc_lobby_check_display_name_required", true);
54
+end
55
+load_config();
46 56
 
47 57
 local lobby_muc_service;
48 58
 local main_muc_service;
@@ -84,6 +94,9 @@ function filter_stanza(stanza)
84 94
             end
85 95
 
86 96
             return nil;
97
+        elseif stanza.name == 'iq' and stanza:get_child('query', DISCO_INFO_NS) then
98
+            -- allow disco info from the lobby component
99
+            return stanza;
87 100
         end
88 101
 
89 102
         return nil;
@@ -125,7 +138,24 @@ function process_lobby_muc_loaded(lobby_muc, host_module)
125 138
     filters.add_filter_hook(filter_session);
126 139
 
127 140
     -- Advertise lobbyrooms support on main domain so client can pick up the address and use it
128
-    module:add_identity('component', 'lobbyrooms', lobby_muc_component_config);
141
+    module:add_identity('component', LOBBY_IDENTITY_TYPE, lobby_muc_component_config);
142
+
143
+    -- Tag the disco#info response with a feature that display name is required
144
+    -- when the conference name from the web request has a lobby enabled.
145
+    host_module:hook("host-disco-info-node", function (event)
146
+        local session, reply, node = event.origin, event.reply, event.node;
147
+        if node == LOBBY_IDENTITY_TYPE
148
+            and session.jitsi_web_query_room
149
+            and main_muc_service
150
+            and check_display_name_required then
151
+            local room = main_muc_service.get_room_from_jid(
152
+                jid_bare(session.jitsi_web_query_room .. '@' .. main_muc_component_config));
153
+            if room and room._data.lobbyroom then
154
+                reply:tag("feature", { var = DISPLAY_NAME_REQUIRED_FEATURE }):up();
155
+            end
156
+        end
157
+        event.exists = true;
158
+    end);
129 159
 
130 160
     local room_mt = lobby_muc_service.room_mt;
131 161
     -- we base affiliations (roles) in lobby muc component to be based on the roles in the main muc
@@ -256,3 +286,25 @@ process_host_module(main_muc_component_config, function(host_module, host)
256 286
         end
257 287
     end, -4); -- the default hook on members_only module is on -5
258 288
 end);
289
+
290
+-- Extract 'room' param from URL when session is created
291
+function update_session(event)
292
+    local session = event.session;
293
+
294
+    if session.jitsi_web_query_room then
295
+        -- no need for an update
296
+        return;
297
+    end
298
+
299
+    local query = event.request.url.query;
300
+    if query ~= nil then
301
+        local params = formdecode(query);
302
+        -- The room name and optional prefix from the web query
303
+        session.jitsi_web_query_room = params.room;
304
+        session.jitsi_web_query_prefix = params.prefix or "";
305
+    end
306
+end
307
+
308
+module:hook_global("bosh-session", update_session);
309
+module:hook_global("websocket-session", update_session);
310
+module:hook_global('config-reloaded', load_config);

+ 2
- 2
resources/prosody-plugins/mod_muc_poltergeist.lua View File

@@ -106,8 +106,8 @@ prosody.events.add_handler("pre-jitsi-authentication", function(session)
106 106
 
107 107
     if (session.jitsi_meet_context_user) then
108 108
         local room = get_room(
109
-            session.jitsi_bosh_query_room,
110
-            session.jitsi_bosh_query_prefix);
109
+            session.jitsi_web_query_room,
110
+            session.jitsi_web_query_prefix);
111 111
 
112 112
         if (not room) then
113 113
             return nil;

+ 2
- 1
resources/prosody-plugins/mod_token_verification.lua View File

@@ -93,7 +93,8 @@ for event_name, method in pairs {
93 93
             return;
94 94
         end
95 95
 
96
-        if not session.auth_token then
96
+        -- jitsi_meet_room is set after the token had been verified
97
+        if not session.auth_token or not session.jitsi_meet_room then
97 98
             session.send(
98 99
                 st.error_reply(
99 100
                     stanza, "cancel", "not-allowed", "Room modification disabled for guests"));

Loading…
Cancel
Save