aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-03-04 18:40:43 +0100
committerKim Alvefur <zash@zash.se>2023-03-04 18:40:43 +0100
commit4d46c278406e72d934823117eddfa2e7a35c8cc1 (patch)
treeea1df426b132ae01bd17d98352d3c646cef463a9 /core
parent7b7cad2b668fb94f84aa24396d3c2f72121d0083 (diff)
downloadprosody-4d46c278406e72d934823117eddfa2e7a35c8cc1.tar.gz
prosody-4d46c278406e72d934823117eddfa2e7a35c8cc1.zip
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?
Diffstat (limited to 'core')
-rw-r--r--core/usermanager.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 3afb5037..5fe8022f 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -53,6 +53,7 @@ local fallback_authz_provider = {
get_users_with_role = function (role_name) end;
add_default_permission = function (role_name, action, policy) end;
get_role_by_name = function (role_name) end;
+ get_all_roles = function () end;
};
local provider_mt = { __index = new_null_provider() };
@@ -293,6 +294,11 @@ local function get_role_by_name(role_name, host)
return hosts[host].authz.get_role_by_name(role_name);
end
+local function get_all_roles(host)
+ if host and not hosts[host] then return false; end
+ return hosts[host].authz.get_all_roles();
+end
+
return {
new_null_provider = new_null_provider;
initialize_host = initialize_host;
@@ -320,6 +326,7 @@ return {
set_jid_role = set_jid_role;
get_jids_with_role = get_jids_with_role;
get_role_by_name = get_role_by_name;
+ get_all_roles = get_all_roles;
-- Deprecated
is_admin = is_admin;