SecurityContextHelper.getAuthentication() returns AnonymousUser

Hello,
We have a Jmix 2.2.3 application with reverse proxy, LDAP Authentication and CustomUserSynchronizationStrategy for creating users on their first login with LDAP credentials.

We are facing an issue where 3 out of 4 times that a user is trying to login for 1st time in the application, he gets RuntimeException: Authentication principal must be UserDatails . After some debugging we saw that SecurityContextHelper.getAuthentication() returns AnonymousUser.

After 3-4 tries the user successfully logs in and his user is being created.

Can you please help us to resolve this issue?
Thank you,
Ilias

1 Like

Hi,

It is hard to say without having a reproducible test case or at least the full stacktrace of the exception. Could you reproduce the problem on a small demo project and attach it here?

We will also need:

  1. Exact steps describing how to get the exception
  2. Full exception stacktrace

It will be useful if you set the debug logging level for spring security:

logging.level.org.springframework.security=debug