|
@@ -33,6 +33,13 @@ log("debug",
|
33
|
33
|
tostring(host), tostring(token_util.appId), tostring(token_util.appSecret),
|
34
|
34
|
tostring(token_util.allowEmptyToken));
|
35
|
35
|
|
|
36
|
+-- option to disable room modification (sending muc config form) for guest that do not provide token
|
|
37
|
+local require_token_for_moderation;
|
|
38
|
+local function load_config()
|
|
39
|
+ require_token_for_moderation = module:get_option_boolean("token_verification_require_token_for_moderation");
|
|
40
|
+end
|
|
41
|
+load_config();
|
|
42
|
+
|
36
|
43
|
local function verify_user(session, stanza)
|
37
|
44
|
log("debug", "Session token: %s, session room: %s",
|
38
|
45
|
tostring(session.auth_token),
|
|
@@ -70,3 +77,30 @@ module:hook("muc-occupant-pre-join", function(event)
|
70
|
77
|
log("debug", "pre join: %s %s", tostring(room), tostring(stanza));
|
71
|
78
|
return verify_user(origin, stanza);
|
72
|
79
|
end);
|
|
80
|
+
|
|
81
|
+for event_name, method in pairs {
|
|
82
|
+ -- Normal room interactions
|
|
83
|
+ ["iq-set/bare/http://jabber.org/protocol/muc#owner:query"] = "handle_owner_query_set_to_room" ;
|
|
84
|
+ -- Host room
|
|
85
|
+ ["iq-set/host/http://jabber.org/protocol/muc#owner:query"] = "handle_owner_query_set_to_room" ;
|
|
86
|
+} do
|
|
87
|
+ module:hook(event_name, function (event)
|
|
88
|
+ local session, stanza = event.origin, event.stanza;
|
|
89
|
+
|
|
90
|
+ -- if we do not require token we pass it through(default behaviour)
|
|
91
|
+ -- or the request is coming from admin (focus)
|
|
92
|
+ if not require_token_for_moderation or is_admin(stanza.attr.from) then
|
|
93
|
+ return;
|
|
94
|
+ end
|
|
95
|
+
|
|
96
|
+ if not session.auth_token then
|
|
97
|
+ session.send(
|
|
98
|
+ st.error_reply(
|
|
99
|
+ stanza, "cancel", "not-allowed", "Room modification disabled for guests"));
|
|
100
|
+ return true;
|
|
101
|
+ end
|
|
102
|
+
|
|
103
|
+ end, -1); -- the default prosody hook is on -2
|
|
104
|
+end
|
|
105
|
+
|
|
106
|
+module:hook_global('config-reloaded', load_config);
|