Another member of the community has created a keycloak extension. it might be worth taking a look to see if that solves the problem: