M
M
Mark Ivanych2016-02-18 10:03:58
JavaScript
Mark Ivanych, 2016-02-18 10:03:58

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);

The problem is that the site has authorization through VK, so you need to implement a new implements UserDetailsService and pass vkId in it under the guise of username , but this method seems very clumsy to me. You will also have to bin two TokenBasedRememberMeServices .
Explain how to do it right? Implement your rememberMeServices? But it's not sickly so you have to implement

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2016-02-18
@unitby

Inherit rememberMeServices adding only the necessary functionality and not implement it all in any way?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question