Comparison

mod_firewall/mod_firewall.lua @ 5002:84997bc3f92e

mod_firewall: Update for role-auth (backwards compatible) Probably worth investigating mod_compat_roles in the future.
author Matthew Wild <mwild1@gmail.com>
date Thu, 11 Aug 2022 17:04:53 +0100
parent 4608:4e8fa75cc678
child 5160:8474a3b80200
comparison
equal deleted inserted replaced
5001:cb19cb1c03d6 5002:84997bc3f92e
3 local resolve_relative_path = require "core.configmanager".resolve_relative_path; 3 local resolve_relative_path = require "core.configmanager".resolve_relative_path;
4 local envload = require "util.envload".envload; 4 local envload = require "util.envload".envload;
5 local logger = require "util.logger".init; 5 local logger = require "util.logger".init;
6 local it = require "util.iterators"; 6 local it = require "util.iterators";
7 local set = require "util.set"; 7 local set = require "util.set";
8
9 local have_features, features = pcall(require, "core.features");
10 features = have_features and features.available or set.new();
8 11
9 -- [definition_type] = definition_factory(param) 12 -- [definition_type] = definition_factory(param)
10 local definitions = module:shared("definitions"); 13 local definitions = module:shared("definitions");
11 14
12 -- When a definition instance has been instantiated, it lives here 15 -- When a definition instance has been instantiated, it lives here
179 bare_to = { depends = { "jid_bare", "to" }, local_code = "local bare_to = jid_bare(to)"}; 182 bare_to = { depends = { "jid_bare", "to" }, local_code = "local bare_to = jid_bare(to)"};
180 bare_from = { depends = { "jid_bare", "from" }, local_code = "local bare_from = jid_bare(from)"}; 183 bare_from = { depends = { "jid_bare", "from" }, local_code = "local bare_from = jid_bare(from)"};
181 group_contains = { 184 group_contains = {
182 global_code = [[local group_contains = module:depends("groups").group_contains]]; 185 global_code = [[local group_contains = module:depends("groups").group_contains]];
183 }; 186 };
184 is_admin = { global_code = [[local is_admin = require "core.usermanager".is_admin;]]}; 187 is_admin = features:contains("permissions") and { global_code = [[local is_admin = require "core.usermanager".is_admin;]]} or nil;
188 get_jid_role = require "core.usermanager".get_jid_role and { global_code = [[local get_jid_role = require "core.usermanager".get_jid_role;]] } or nil;
185 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza;]] }; 189 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza;]] };
186 zone = { global_code = function (zone) 190 zone = { global_code = function (zone)
187 local var = zone; 191 local var = zone;
188 if var == "$local" then 192 if var == "$local" then
189 var = "_local"; -- See #1090 193 var = "_local"; -- See #1090