0
votes

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?

1
Do you use a UserDetailsService to load the user from database?shazin
Possible duplicate of Spring Security: custom userdetailsgpeche

1 Answers

0
votes

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