# HG changeset patch # User Matthew Wild # Date 1610905883 0 # Node ID f6da234b21b834fb2b9dfcf3f77e5589e9f27aff # Parent c0b1b2a61e3c014c3a435bb16f7724a5cb3bfb9b mod_http_admin_api: Add groups property to users diff -r c0b1b2a61e3c -r f6da234b21b8 mod_http_admin_api/mod_http_admin_api.lua --- a/mod_http_admin_api/mod_http_admin_api.lua Sun Jan 17 17:50:42 2021 +0000 +++ b/mod_http_admin_api/mod_http_admin_api.lua Sun Jan 17 17:51:23 2021 +0000 @@ -8,6 +8,8 @@ local tokens = module:depends("tokenauth"); local mod_pep = module:depends("pep"); +local group_memberships = module:open_store("groups", "map"); + local json_content_type = "application/json"; local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); @@ -149,9 +151,21 @@ end end + local groups; + do + local group_set = group_memberships:get_all(username); + if group_set and next(group_set) then + groups = {}; + for group_id in pairs(group_set) do + table.insert(groups, group_id); + end + end + end + return { username = username; display_name = display_name; + groups = groups; }; end