I have started switching my application over to use Spring Security. I have a custom UserDetailsServiceImpl
which is returning my custom UserDetails
which contain the standard Spring stuff (roles, etc.), as well as some application specific references, IE: currentWorkspace
.
I am tracking the currentWorkspace
in the DB and it is loaded properly in the initial loadUserByUsername
. In my Spring MVC when I change something in my UserDetails
like currentWorkspace
, how can I trigger a reload of the UserDetails
, or modify the current Principal
and push it into the session in place of the outdated one?
Is it as simple as just calling loadUserByUsername
in my UserDetailsService
and Spring will handle the rest? Do I have to mess around with the SecurityContextHolder.getContext().getAuthentication()
and set something there? I figured this was something simple but can't figure out what to do.