I think I may know what the problem is. The registration page is split
into multiple different processors. The user is created in one
processor and the flow context is set to the user. The problem is, then
context stores the user as an id and every time a processor needs the
user it does a lookup by id. So, what I think is happening in your
situation is that you are creating multiple different proxy objects in
the same transaction and your transaction commit logic is confused by this.
I don't think the Keycloak runtime can keep track of UserModels loaded
in the transaction and bypass invoking the UserStorageProvider methods.
Why? Mainly because of bulk query methods.... So, you'll have to keep
track of the proxies you create in your provider. Hopefully that makes
sense.
On 11/30/16 11:29 AM, Nikolay Petrovski wrote:
Hi,
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 :
...
@Override
public UserModel addUser(final RealmModel realm, String username) {
// Add local storage user
UserModel user = session.userLocalStorage().addUser(realm,
username);
user.setFederationLink(model.getId());
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?
_______________________________________________
keycloak-user mailing list
keycloak-user(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user