It seems that you need to use a different SecurityContextHolder
strategy. See https://docs.spring.io/spring-security/site/docs/5.0.0.RELEASE/reference/htmlsingle/#securitycontextholder-securitycontext-and-authentication-objects for more details on how to change it