Comparison

core/usermanager.lua @ 12920:cdb996637b08

authz: Add method for retrieving all roles Some of the OAuth stuff highlights a small need to retrieve a list of roles somehow. Handy if you ever need a role selector in adhoc or something. Unless there's some O(n) thing we were avoiding?
author Kim Alvefur <zash@zash.se>
date Sat, 04 Mar 2023 18:40:43 +0100
parent 12906:e282c92ded0e
child 12972:ead41e25ebc0
comparison
equal deleted inserted replaced
12919:7c0e5c7eff7c 12920:cdb996637b08
51 set_jid_role = function (jid, role) end; 51 set_jid_role = function (jid, role) end;
52 52
53 get_users_with_role = function (role_name) end; 53 get_users_with_role = function (role_name) end;
54 add_default_permission = function (role_name, action, policy) end; 54 add_default_permission = function (role_name, action, policy) end;
55 get_role_by_name = function (role_name) end; 55 get_role_by_name = function (role_name) end;
56 get_all_roles = function () end;
56 }; 57 };
57 58
58 local provider_mt = { __index = new_null_provider() }; 59 local provider_mt = { __index = new_null_provider() };
59 60
60 local function initialize_host(host) 61 local function initialize_host(host)
289 290
290 local function get_role_by_name(role_name, host) 291 local function get_role_by_name(role_name, host)
291 if host and not hosts[host] then return false; end 292 if host and not hosts[host] then return false; end
292 if type(role_name) ~= "string" then return false; end 293 if type(role_name) ~= "string" then return false; end
293 return hosts[host].authz.get_role_by_name(role_name); 294 return hosts[host].authz.get_role_by_name(role_name);
295 end
296
297 local function get_all_roles(host)
298 if host and not hosts[host] then return false; end
299 return hosts[host].authz.get_all_roles();
294 end 300 end
295 301
296 return { 302 return {
297 new_null_provider = new_null_provider; 303 new_null_provider = new_null_provider;
298 initialize_host = initialize_host; 304 initialize_host = initialize_host;
318 get_users_with_role = get_users_with_role; 324 get_users_with_role = get_users_with_role;
319 get_jid_role = get_jid_role; 325 get_jid_role = get_jid_role;
320 set_jid_role = set_jid_role; 326 set_jid_role = set_jid_role;
321 get_jids_with_role = get_jids_with_role; 327 get_jids_with_role = get_jids_with_role;
322 get_role_by_name = get_role_by_name; 328 get_role_by_name = get_role_by_name;
329 get_all_roles = get_all_roles;
323 330
324 -- Deprecated 331 -- Deprecated
325 is_admin = is_admin; 332 is_admin = is_admin;
326 }; 333 };