Keycloak Group Select Extension
Purpose
The purpose of this extension is to add another form after initial login where a user is forced to select one of their groups that matches a configurable regular expression. Once selected this is pushed into a configurable user attribute with their groups that didn't match the expression that can be then mapped into the user claim as desired.
Setup
- Build the java project with gradle.
gradle build
- Deploy the resulting jar (./bin/lib/keycloakgroupextension.jar) by placing it in the standalone/deployments folder of your keycloak install.
- Deploy the ftl (./group-question.ftl) by placing it in themes/base/login/ folder of your keycloak install.
- in the keycloak admin for the desired realm(s).
- Navigate to Authentication
- Copy the existing browser flow to a new flow
- In the forms section of your new flow, click "Actions" Then "Add Execution"
- Select "Group Question"
- On the page of your new flow click "Actions" to the side of group question then "Config"
- Enter anything desired for the alias and fill in the rest of the values as make sense for your application.