Hello,
there is the following problem/scenario: I need to integrate users from a user database to keycloak via user federation.
I can add the user federation provider successfully and was querying the users via UserStorageProviderFactory.
My code is based on this example:
https://github.com/dasniko/keycloak-user-spi-demo
The class is implementing the following interfaces.
public class DemoUserStorageProvider implements UserStorageProvider, UserLookupProvider, UserQueryProvider, CredentialInputUpdater, CredentialInputValidator
@Override
public List<UserModel> searchForUser(Map<String, String> params, RealmModel realm, int firstResult,
int maxResults) {
TypedQuery<Nutzer> query = entityManager.createQuery("select n from Nutzer n", Nutzer.class);
List<Nutzer> findAllUsers = query.getResultList();
return findAllUsers.stream().map(user -> new UserAdapter(session, realm, model, user))
.collect(Collectors.toList());
}
Problem: I can return Users wrapped around an UserAdapter. But the users also have a usergroup which needs to be generated in advance.
My question is now, how can I also add usergroups automatically? Shouldn´t be there also kind of GroupStorageProvider? I don´t really find the entry point how to create groups automatically with keycloak startup.
Thank you for your help!