view mod_groups_oidc/mod_groups_oidc.lua @ 5801:73887dcb2129

mod_pubsub_serverinfo: New module that uses pub/sub to make accessible server info This first implemetnation is laughably simple: it only adds a disco#info feature. This flags 'opt-in' for inclusion of local domain names in the data exposed by other domains (per the domain), which will allow servers to be listed in the XMPP Network Graph at https://xmppnetwork.goodbytes.im Hopefully, this bare-boned implementation acts as a stepping stone for future improvements.
author Guus der Kinderen <guus.der.kinderen@gmail.com>
date Thu, 28 Dec 2023 11:02:35 +0100
parents 7d9dce4e7dd0
children
line wrap: on
line source

local array = require "util.array";

module:add_item("openid-claim", "groups");

local group_memberships = module:open_store("groups", "map");
local function user_groups(username)
	return pairs(group_memberships:get_all(username) or {});
end

module:hook("token/userinfo", function(event)
	local userinfo = event.userinfo;
	if event.claims:contains("groups") then
		userinfo.groups = array(user_groups(event.username));
	end
end);