[keycloak-user] Custom UserStorage module issue

Nikolay Petrovski to.petrovski at gmail.com
Wed Nov 30 11:29:22 EST 2016


I have the following problem - trying to create a custom *UserStorageProvider
*over my new installation of *Keycloak 2.4.0.Final.* The Kc instance is
configured to work with MongoDB local storage, and I want to attach another
external user storage.

Everything in my custom module seems to work fine, until it gets to :


public UserModel addUser(final RealmModel realm, String username) {
        // Add local storage user
        UserModel user = session.userLocalStorage().addUser(realm,

        return proxy(realm, user, remoteUser);

That *proxy *method extends with several UserModelDelegate(s), one of them
is a KeycloakTransaction-driven model delegate, which should does external
storage user creation on commit() action.

Pretty much the same code as the LDAP UserStoreProvider.

The problem comes when I try to register new user and a *commit()* is
called (KeycloakTransaction is closed) only "email" and "custom attribute"
properties are filled (setEmail() and setAttribute() are called) within my
delegated object. The user I am trying to create in my external source has
only "Email" and "Phone (as a custom attribute)" values populated after
registration process.

Any idea if I miss something? Or, any other way I can get the whole
UserModel populated while register new user in Keycloak, so then I can send
it over to my external user storage?

More information about the keycloak-user mailing list