UiEventPublisher for in-memory users

Hi,

we implemented OIDC authentication in our application and don’t persist users that are created on login in our database - they are in-memory only.

Unfortunately, UiEventPublisher.sendEventToUserSessions() uses systemAuthenticator.runWithUser(), which prompts an attempt to load the given user from the db, that obviously does not work with in-memory users and throws a UsernameNotFoundException.

We recreated some of the event-publishing logic and got it to work for now - however, among other things we use io.jmix.flowui.sys.SessionHolder for our own implementation, which isn’t really ideal.

Is there any way to get the UiEventPublisher to work with in-memory users?

Thanks!

Hello Daniel.

systemAuthenticator.runWithUser() eventually tries to get user from UserRepository.
So if it’s default DatabaseUserRepository - it will not find in-memory users and failed.

The feature which should help is CompositeUserRepository.
It collects all UserRepository beans found in application and delegates user acquiring to all of them one-by-one till it is found.

So you should have your some InMemoryUserRepository and create primary bean CompositeUserRepository (remove @Primary from other UserRepository bean you have in project).

Here is an example for the LDAP, but the concept it the same - In-memory User Management :: Jmix Documentation

Regards,
Ivan