Restricted mapper ‘Group Membership’

With the ‘Group Membership’ mapper, all groups of which the user is a member are transferred as one claim. However, there are cases where, for data protection reasons, only one group including its subgroups may be transferred. Unfortunately, I can’t find a way to restrict the mapper.

For example, the user is a member of the groups Foo.B and Bar.C. But for data protection reasons, only the group Foo and its subgroups (in this case B) may be transferred.

I would therefore be grateful for any tips.

Thank you

Keycloak does not support this ootb, you’d have to write a custom mapper.

Thanks.
And how do you do that? I couldn’t find anything about it in the documentation.