"Fossies" - the Fresh Open Source Software Archive 
Member "jitsi-meet-6316/resources/prosody-plugins/mod_filter_iq_jibri.lua" (5 Jul 2022, 2248 Bytes) of package /linux/misc/jitsi-meet-6316.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 local st = require "util.stanza";
2 local is_feature_allowed = module:require "util".is_feature_allowed;
3 local token_util = module:require "token/util".new(module);
4
5 local accepted_rayo_iq_token_issuers = module:get_option_array("accepted_rayo_iq_token_issuers");
6
7 -- filters jibri iq in case of requested from jwt authenticated session that
8 -- has features in the user context, but without feature for recording
9 module:hook("pre-iq/full", function(event)
10 local stanza = event.stanza;
11 if stanza.name == "iq" then
12 local jibri = stanza:get_child('jibri', 'http://jitsi.org/protocol/jibri');
13 if jibri then
14 local session = event.origin;
15 local token = session.auth_token;
16
17 if jibri.attr.action == 'start' then
18 local errorReason;
19 if accepted_rayo_iq_token_issuers then
20 local iq_token = jibri.attr.token;
21 if iq_token then
22 local session = {};
23 session.auth_token = iq_token;
24 local verified, reason = token_util:process_and_verify_token(
25 session, accepted_rayo_iq_token_issuers);
26 if verified then
27 return nil; -- this will proceed with dispatching the stanza
28 end
29 errorReason = reason;
30 else
31 errorReason = 'No recording token provided';
32 end
33
34 module:log("warn", "not a valid token %s", tostring(errorReason));
35 session.send(st.error_reply(stanza, "auth", "forbidden"));
36 return true;
37 end
38
39 if token == nil
40 or not is_feature_allowed(session,
41 (jibri.attr.recording_mode == 'file' and 'recording' or 'livestreaming')
42 ) then
43 module:log("info",
44 "Filtering jibri start recording, stanza:%s", tostring(stanza));
45 session.send(st.error_reply(stanza, "auth", "forbidden"));
46 return true;
47 end
48 end
49 end
50 end
51 end);