From a848395e2bff6ec5799823c609b4e596e0d3e6f5 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 29 Apr 2021 13:09:29 +0200 Subject: [PATCH] auth-backend: getEntityClaims make sure target is group kind We are interested in the User isMemberOf Group relation. So this is just an additional check that the target is of Group kind. Signed-off-by: Himanshu Mishra --- plugins/auth-backend/src/lib/catalog/helpers.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/auth-backend/src/lib/catalog/helpers.ts b/plugins/auth-backend/src/lib/catalog/helpers.ts index c2dfe12455..e155c7defe 100644 --- a/plugins/auth-backend/src/lib/catalog/helpers.ts +++ b/plugins/auth-backend/src/lib/catalog/helpers.ts @@ -26,7 +26,11 @@ export function getEntityClaims(entity: UserEntity): TokenParams['claims'] { const membershipRefs = entity.relations - ?.filter(r => r.type === RELATION_MEMBER_OF) + ?.filter( + r => + r.type === RELATION_MEMBER_OF && + r.target.kind.toLocaleLowerCase() === 'group', + ) .map(r => stringifyEntityRef(r.target)) ?? []; return {