As of Spring Security doc: 34.1 @EnableWebMvcSecurity states, the @EnableWebMvcSecurity
was replaced by @EnableWebSecurity
.
But when I try
AuthenticationPrincipal is empty.
But I can get the UserDetails by the traditional way, like this:SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Configuring of argument-resolvers
helped for me
Also you can see 34.2 @AuthenticationPrincipal section
Once AuthenticationPrincipalArgumentResolver is properly configured, you can be entirely decoupled from Spring Security in your Spring MVC layer.
How i understand this mean you should add argument resolver manually. Or
By using Section 34.1, “@EnableWebMvcSecurity” you will automatically have this added to your Spring MVC configuration
Also related question