vendredi 15 mai 2020

Spring SecurityContextHolder getPrincipal model.User vs. userDetails.User

During runtime, when i retrieve autheticated user like this:

SecurityContextHolder.getContext().getAuthentication().getPrincipal()

I get User from my model of my application:

test.package.model.User

When i retrieve user during testing, so i get user from userDetails

org.springframework.security.core.userdetails.User

I would like to keep it konsistent during runtime and testtime. Which User-Type should i use and why?

Aucun commentaire:

Enregistrer un commentaire