Auto assign user to group

I’m managing our customers access to our FE machine in realms (each customer has its own realm)
I also have 3 different groups in each realm (viewer,operator and admin)
Is there an option to auto add specific users (by their email address f.e) to a group after their first login to the realm (using oidc brokering)?

Thanks in advance,

Maybe an authenticator which checks the logged-in users attributes and adds them to the desired group could be an option. The authenticator has to be added to an authentication flow which is configured as “Post Login Flow” in the OIDC broker’s configuration.

Within the authenticator, you can access the realm model, query the groups model by id, access the user model and so on…