title: Inject user details as session scoped bean
body: <p>A while back I came across an example of an elegant way of getting hold of information about the currently logged in user in Spring controllers. But now I can't seem to remember exactly how, and I'm unable to find any examples (most are with SecurityContextHolder or other older ways of doing this). As far as I remember it was something like:</p>
  
  <pre><code>@Controller
  public class SomeController {
      @Autowired
      private Principal principal;
  </code></pre>
  
  <p>And then it would inject a different object based on the context (which user was behind the invocation). But I can't exactly recall how it was done, or which object was injected. Can anyone refresh my memory? I'm using Keycloak as IDP.</p>