Answer the question
In order to leave comments, you need to log in
What is the correct way to use remember me and Oauth2 in Spring Security?
Hello,
After registering on the site, I authorize the user and write down remember-me in the usual way:
// Биним в конфигурации
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
TokenBasedRememberMeServices rememberMeServices
= new TokenBasedRememberMeServices("123", basicUserDetailsService);
return rememberMeServices;
}
// Используем при регистрации
@Autowired
private TokenBasedRememberMeServices rememberMeServices;
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
token.setDetails(new WebAuthenticationDetails(request));
SecurityContextHolder.getContext().setAuthentication(token);
rememberMeServices.loginSuccess(request, response, token);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question