Reputation: 24659
I have a JPA entity called Member
. I would like for this entity to implement Spring Security UserDetails
and implement a custom JPA-based UserService
.
Before doing so, I have a few points of concern that I would like to sort:
Member
entity has got quite a few properties. Can the fact that Member
now implements UserDetails
and is therefore stored into HttpSession (see HttpSessionSecurityContextRepository
) impact session usage significantly?Member
by just calling: SecurityContextHolder.getContext().getAuthentication().getPrincipal();
and expect all its properties to remain synchronized properly when they are updated elsewhere?Upvotes: 2
Views: 662
Reputation: 47280
impact session usage significantly?
No.
expect all its properties to remain synchronized properly when they are updated elsewhere?
No, you'll have to manage that yourself ..., ie when you update it somewhere, make sure you also update the instance in memory :
Member member = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
member.setYourField(yourValue); //
Upvotes: 2