0

I have created a Spring security application. When the user logs in the user name and roles get stored in Security Context. The same can be retrieved using Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();

How can I store the additional user information like user ID, Email, Associated Branch ID etc in the context?

Vivek
  • 53
  • 9
  • Do you use a `UserDetailsService` to load the user from database? – shazin May 10 '18 at 08:23
  • Possible duplicate of [Spring Security: custom userdetails](https://stackoverflow.com/questions/10607696/spring-security-custom-userdetails) – gpeche May 10 '18 at 08:26

1 Answers1

0

The basic idea is to implement a custom UserDetails. You can read this question for a longer explanation.

gpeche
  • 21,974
  • 5
  • 38
  • 51