Reputation: 117
I trying authenticate user in Spring Security application via oAuth. I'm already received token and user's data.
How can I authenticate user manually without password and classic login form? Thank you.
Upvotes: 7
Views: 10273
Reputation: 2273
Something like this:
Authentication authentication = new UsernamePasswordAuthenticationToken(person, null, person.getAuthorities());
log.debug("Logging in with {}", authentication.getPrincipal());
SecurityContextHolder.getContext().setAuthentication(authentication);
Where person
is your UserDetailsBean object.
Upvotes: 22