User storage federation provider - writable edit mode


Please, I need some guidance on how to enable writable edit mode on a custom user storage federation provider.

I’m taking this project as a starting point: GitHub - hdensity/keycloak-crowd-user-federation: Crowd based User Federation for Keycloak

And I’m trying to figure out how to go from read-only to writable user properties. I’ve already gone through the official documentation (Server Developer Guide) and several example projects (e.g: keycloak-quickstarts/user-storage-jpa at latest · keycloak/keycloak-quickstarts · GitHub) but with no luck so far. What I’m doing is implementing the setter methods from the CrowdUserAdapter class, replacing the throw new ReadOnlyException(); statements with something like this:


After deploying it to Keycloak, I can successfully save modifications on a user profile from the admin console but nothing really happens, the changes are not applied neither sent to Crowd. Also trying to modify the profile from the Personal Info form of an user manage account, results in the following error popping in: “Conflict: usernameExistsMessage”. Keycloak logs doesn’t show any feedback on the process.

Am I missing some key part of the implementation?

Thanks in advance.

Finally found out after banging my head against Keycloak source code. The key is in the AbstractUserAdapterFederatedStorage class comment:

Assumes everything is managed by federated storage except for username. getId() returns a default value of “f:” + providerId + “:” + getUsername(). UserModel properties like enabled, firstName, lastName, email, etc. are all stored as attributes in federated storage.

So, except from setUsername(String username), any other user property or attribute has to be treated in the setAttribute(String name, List<String> values) method.