简体   繁体   中英

Spring Security Additional Logged in user information

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM