Get list of associated groups of a user inside a custom Authenticator

This is my first time trying KC.
I’m trying to implement a tenant selector during login. I have found a sample somewhere, but this sample uses a hard coded list of tenants.

In my case the groups a user belongs to are the tenants. I would like to get the groups (with their custom properties) inside my Authenticator implementation, and set that as a session note.

Any pointers are greatly appreciated.

I have discovered context.getUser().getGroups().

Now I have to pass this list to the form somehow.

  • Is public void authenticate(AuthenticationFlowContext context) the correct place to do this?
  • How do I pass the data? I see context.form().setAttribute() and context.form().setFormData() or something else? (first time freemarker user too)