'keycloak: add a user from a deployed authenticator without using the keycloak admin client
I have a custom authenticator which should create a user in case they don't exist. The following snippet creates a user:
@Override
public void authenticate(AuthenticationFlowContext context) {
String someUserId = ...;
.....
AuthenticatorConfigModel config = context.getAuthenticatorConfig();
KeycloakSession keycloakSession = context.getSession();
UserProvider userProvider = keycloakSession.userStorageManager();
RealmModel realmModel = context.getRealm();
UserModel user = userProvider.addUser(realmModel, someUserId); <-- this creates the user
}
I can also create the UserRepresentation in the following way:
UserRepresentation rep = new UserRepresentation();
rep.setUsername(...);
rep.setFirstName(...);
rep.setLastName(...);
rep.setAttributes(Collections.singletonMap("someAttribute", Collections.singletonList(...)));
rep.setEnabled(true);
Is there a way to update the user representation without using the keycloak admin client with its REST API Calls? Of course, I can use it but I thought there could be an easier way if I am deploying the code to the keycloak deployments themselves.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
