Selaa lähdekoodia

Adding whitelist and move away from using custom field for password. (#6621)

* Adding whitelist and move away from using custom field for password.

We re-use room lock for lobby password.

* Make sure we do not run muc-occupant-pre-join for non members only rooms.

* Destroying lobby room, when main room is destroyed or membersonly is disabled.

* Adds destroy reason.

* Clears lobby room instance on destroy.

Fixes problem with on/off/on of lobby feature.

* Add lobby room jid only when members only is on.

* Sends main room jid on lobby destroy.

We can use that in client loggic to auto-join lobby participants to main room as lobby is disabled while waiting.

* fix: Fixes using is_healthcheck_room.

* squash: Enables lobby rooms feature by default.

* chore(deps): Update lib-jitsi-meet, to enable lobby rooms.
master
Дамян Минков 5 vuotta sitten
vanhempi
commit
78b01d2c97
No account linked to committer's email address

+ 10
- 0
doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example Näytä tiedosto

46
             "speakerstats";
46
             "speakerstats";
47
             "turncredentials";
47
             "turncredentials";
48
             "conference_duration";
48
             "conference_duration";
49
+            "muc_lobby_rooms";
49
         }
50
         }
50
         c2s_require_encryption = false
51
         c2s_require_encryption = false
52
+        lobby_muc = "lobby.jitmeet.example.com"
53
+        main_muc = "conference.jitmeet.example.com"
54
+        -- muc_lobby_whitelist = { "recorder.jitmeet.example.com" } -- Here we can whitelist jibri to enter lobby enabled rooms
51
 
55
 
52
 Component "conference.jitmeet.example.com" "muc"
56
 Component "conference.jitmeet.example.com" "muc"
53
     storage = "memory"
57
     storage = "memory"
81
 
85
 
82
 Component "conferenceduration.jitmeet.example.com" "conference_duration_component"
86
 Component "conferenceduration.jitmeet.example.com" "conference_duration_component"
83
     muc_component = "conference.jitmeet.example.com"
87
     muc_component = "conference.jitmeet.example.com"
88
+
89
+Component "lobby.jitmeet.example.com" "muc"
90
+    storage = "memory"
91
+    restrict_room_creation = true
92
+    muc_room_locking = false
93
+    muc_room_default_public_jids = true

+ 2
- 2
package-lock.json Näytä tiedosto

10935
       }
10935
       }
10936
     },
10936
     },
10937
     "lib-jitsi-meet": {
10937
     "lib-jitsi-meet": {
10938
-      "version": "github:jitsi/lib-jitsi-meet#c94f6a570f69ebfe18de6c1549cc76370c791468",
10939
-      "from": "github:jitsi/lib-jitsi-meet#c94f6a570f69ebfe18de6c1549cc76370c791468",
10938
+      "version": "github:jitsi/lib-jitsi-meet#c700fbd584a315d4398c481ecc2286c4a711c20c",
10939
+      "from": "github:jitsi/lib-jitsi-meet#c700fbd584a315d4398c481ecc2286c4a711c20c",
10940
       "requires": {
10940
       "requires": {
10941
         "@jitsi/sdp-interop": "1.0.2",
10941
         "@jitsi/sdp-interop": "1.0.2",
10942
         "@jitsi/sdp-simulcast": "0.3.0",
10942
         "@jitsi/sdp-simulcast": "0.3.0",

+ 1
- 1
package.json Näytä tiedosto

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

+ 50
- 36
resources/prosody-plugins/mod_muc_lobby_rooms.lua Näytä tiedosto

8
 -- lobby_muc = "lobby.jitmeet.example.com"
8
 -- lobby_muc = "lobby.jitmeet.example.com"
9
 -- main_muc = "conference.jitmeet.example.com"
9
 -- main_muc = "conference.jitmeet.example.com"
10
 --
10
 --
11
+-- Component "lobby.jitmeet.example.com" "muc"
11
 --     storage = "memory"
12
 --     storage = "memory"
12
 --     muc_room_cache_size = 1000
13
 --     muc_room_cache_size = 1000
13
 --     restrict_room_creation = true
14
 --     restrict_room_creation = true
42
     return ;
42
     return ;
43
 end
43
 end
44
 
44
 
45
+local whitelist = module:get_option_set("muc_lobby_whitelist", {});
46
+
45
 local lobby_muc_service;
47
 local lobby_muc_service;
46
 local main_muc_service;
48
 local main_muc_service;
47
 
49
 
165
 process_host_module(main_muc_component_config, function(host_module, host)
167
 process_host_module(main_muc_component_config, function(host_module, host)
166
     main_muc_service = prosody.hosts[host].modules.muc;
168
     main_muc_service = prosody.hosts[host].modules.muc;
167
 
169
 
168
-    -- adds new field to the form so moderators can use it to set shared password
169
-    host_module:hook('muc-config-form', function(event)
170
-        table.insert(event.form, {
171
-            name = 'muc#roomconfig_lobbypassword';
172
-            type = 'text-private';
173
-            label = 'Shared Password';
174
-            value = '';
175
-        });
176
-    end, 90-4);
177
-
178
     -- hooks when lobby is enabled to create its room, only done here or by admin
170
     -- hooks when lobby is enabled to create its room, only done here or by admin
179
     host_module:hook('muc-config-submitted', function(event)
171
     host_module:hook('muc-config-submitted', function(event)
172
+        local room = event.room;
180
         local members_only = event.fields['muc#roomconfig_membersonly'] and true or nil;
173
         local members_only = event.fields['muc#roomconfig_membersonly'] and true or nil;
181
         if members_only then
174
         if members_only then
182
-            local node = jid_split(event.room.jid);
175
+            local node = jid_split(room.jid);
183
 
176
 
184
             local lobby_room_jid = node .. '@' .. lobby_muc_component_config;
177
             local lobby_room_jid = node .. '@' .. lobby_muc_component_config;
185
             if not lobby_muc_service.get_room_from_jid(lobby_room_jid) then
178
             if not lobby_muc_service.get_room_from_jid(lobby_room_jid) then
186
                 local new_room = lobby_muc_service.create_room(lobby_room_jid);
179
                 local new_room = lobby_muc_service.create_room(lobby_room_jid);
187
-                new_room.main_room = event.room;
188
-                event.room._data.lobbyroom = lobby_room_jid;
180
+                new_room.main_room = room;
181
+                room._data.lobbyroom = new_room;
189
                 event.status_codes["104"] = true;
182
                 event.status_codes["104"] = true;
190
-
191
-                local lobby_password = event.fields['muc#roomconfig_lobbypassword'];
192
-                if lobby_password then
193
-                    new_room.main_room.lobby_password = lobby_password;
194
-                end
195
             end
183
             end
184
+        elseif room._data.lobbyroom then
185
+            room._data.lobbyroom:destroy(room.jid, 'Lobby room closed.');
186
+            room._data.lobbyroom = nil;
187
+        end
188
+    end);
189
+    host_module:hook("muc-room-destroyed",function(event)
190
+        local room = event.room;
191
+        if room._data.lobbyroom then
192
+            room._data.lobbyroom:destroy(nil, 'Lobby room closed.');
193
+            room._data.lobbyroom = nil;
196
         end
194
         end
197
     end);
195
     end);
198
     host_module:hook("muc-disco#info", function (event)
196
     host_module:hook("muc-disco#info", function (event)
199
-        if (event.room._data.lobbyroom) then
197
+        local room = event.room;
198
+        if (room._data.lobbyroom and room:get_members_only()) then
200
             table.insert(event.form, {
199
             table.insert(event.form, {
201
                 name = "muc#roominfo_lobbyroom";
200
                 name = "muc#roominfo_lobbyroom";
202
                 label = "Lobby room jid";
201
                 label = "Lobby room jid";
203
                 value = "";
202
                 value = "";
204
             });
203
             });
205
-            event.formdata["muc#roominfo_lobbyroom"] = event.room._data.lobbyroom;
204
+            event.formdata["muc#roominfo_lobbyroom"] = room._data.lobbyroom.jid;
206
         end
205
         end
207
     end);
206
     end);
208
 
207
 
209
     host_module:hook('muc-occupant-pre-join', function (event)
208
     host_module:hook('muc-occupant-pre-join', function (event)
210
         local room, stanza = event.room, event.stanza;
209
         local room, stanza = event.room, event.stanza;
211
 
210
 
212
-        if is_healthcheck_room(room.jid) then
211
+        if is_healthcheck_room(room.jid) or not room:get_members_only() then
213
             return;
212
             return;
214
         end
213
         end
215
 
214
 
218
             return;
217
             return;
219
         end
218
         end
220
 
219
 
221
-        local password = join:get_child_text("lobbySharedPassword");
222
-        if password and event.room.lobby_password and password == room.lobby_password then
223
-            local invitee = event.stanza.attr.from;
220
+        local invitee = event.stanza.attr.from;
221
+        local invitee_bare_jid = jid_bare(invitee);
222
+        local _, invitee_domain = jid_split(invitee);
223
+        local whitelistJoin = false;
224
+
225
+        -- whitelist participants
226
+        if whitelist:contains(invitee_domain) or whitelist:contains(invitee_bare_jid) then
227
+            whitelistJoin = true;
228
+        end
229
+
230
+        local password = join:get_child_text('password', MUC_NS);
231
+        if password and room:get_password() and password == room:get_password() then
232
+            whitelistJoin = true;
233
+        end
234
+
235
+        if whitelistJoin then
224
             local affiliation = room:get_affiliation(invitee);
236
             local affiliation = room:get_affiliation(invitee);
225
             if not affiliation or affiliation == 0 then
237
             if not affiliation or affiliation == 0 then
226
                 event.occupant.role = 'participant';
238
                 event.occupant.role = 'participant';
227
-                room:set_affiliation(true, jid_bare(invitee), "member");
239
+                room:set_affiliation(true, invitee_bare_jid, "member");
228
                 room:save();
240
                 room:save();
241
+
242
+                return;
229
             end
243
             end
244
+        end
230
 
245
 
231
         -- we want to add the custom lobbyroom field to fill in the lobby room jid
246
         -- we want to add the custom lobbyroom field to fill in the lobby room jid
232
-        elseif room._data.members_only then
233
-            local invitee = event.stanza.attr.from;
234
-            local affiliation = room:get_affiliation(invitee);
235
-            if not affiliation or affiliation == 'none' then
236
-                local reply = st.error_reply(stanza, 'auth', 'registration-required'):up();
237
-                reply.tags[1].attr.code = '407';
238
-                reply:tag('x', {xmlns = MUC_NS}):up();
239
-                reply:tag('lobbyroom'):text(room._data.lobbyroom);
240
-                event.origin.send(reply:tag('x', {xmlns = MUC_NS}));
241
-                return true;
242
-            end
247
+        local invitee = event.stanza.attr.from;
248
+        local affiliation = room:get_affiliation(invitee);
249
+        if not affiliation or affiliation == 'none' then
250
+            local reply = st.error_reply(stanza, 'auth', 'registration-required'):up();
251
+            reply.tags[1].attr.code = '407';
252
+            reply:tag('x', {xmlns = MUC_NS}):up();
253
+            reply:tag('lobbyroom'):text(room._data.lobbyroom.jid);
254
+            event.origin.send(reply:tag('x', {xmlns = MUC_NS}));
255
+            return true;
243
         end
256
         end
244
     end, -4); -- the default hook on members_only module is on -5
257
     end, -4); -- the default hook on members_only module is on -5
245
 end);
258
 end);

Loading…
Peruuta
Tallenna