view mod_groups_oidc/mod_groups_oidc.lua @ 5805:55b99f593c3a

mod_pubsub_serverinfo: Disco/info cache TTL should be configurable This module caches the disco/info results of remote domains. This commit introduces a new configuration option that allows an admin to configure the cache expiry duration.
author Guus der Kinderen <guus.der.kinderen@gmail.com>
date Thu, 04 Jan 2024 12:05:51 +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);