Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't persist attributes in KC 20.0.2 #8

Closed
xgp opened this issue Jan 9, 2023 · 2 comments
Closed

Doesn't persist attributes in KC 20.0.2 #8

xgp opened this issue Jan 9, 2023 · 2 comments

Comments

@xgp
Copy link

xgp commented Jan 9, 2023

Thanks for the great extension. I have used it in previous versions, but I have just noticed that when using it in KC 20.0.2, the user attributes are no longer persisted. I suspect this is more of a Keycloak change than something that changed here, but I wanted to report that it no longer works here.

@ThoreKr
Copy link
Owner

ThoreKr commented Jan 10, 2023

Thanks for the report.
Unfortunately i can't reproduce the issue.
I'm nut running this exact version of the code, but the functional part is identical. Only thing different to the version in the repository were the remainder of the jboss deployment structure and the pinned dependency version of the keycloak libraries.

Are you manually setting these before building?
Otherwise there is an update in the upgrade-20 branch, which also moves to Java 17, to align with future keycloak releases.

@xgp
Copy link
Author

xgp commented Jan 11, 2023

Hi @ThoreKr I made a very simple test, and ran it in KC 20.0.2

This doesn't persist the attribute:

  public void onEvent(final Event event) {
    if (EventType.LOGIN.equals(event.getType())) {
      UserModel u = session.users().getUserById(realm, event.getUserId());
      u.setSingleAttribute("foo", "bar");
    }
  }

This works:

  public void onEvent(final Event event) {
    if (EventType.LOGIN.equals(event.getType())) {
      KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), s -> {
        UserModel u = s.users().getUserById(realm, event.getUserId());
        u.setSingleAttribute("foo", "bar");
      });
    }
  }

I'll put together a sample repo and submit a keycloak issue. This isn't unique to your extension.

@ThoreKr ThoreKr closed this as completed Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants