lorenzodee/spring-security-oauth2-google

Principal not in SecurityContext

Opened this issue · 0 comments

Thanks for the great post @lorenzodee.

The Spring Principal is not in the SecurityContext after the user authenticates. I have tried adding it manually by adding the following line in GoogleUserInfoTokenServices.extractAuthentication just before the return statement:

SecurityContextHolder.getContext().setAuthentication(token);

That seems to work, but if I try to inject the Principal into a @RestController, the following exception is thrown:
java.lang.UnsupportedOperationException: No authentication should be done with this AuthenticationManager.

This seems to be thrown from your NoopAuthenticationManager which seems to imply that I should be using a different Authentication Manager? Which?

Am I missing something here (I'm new to Spring Security)?