Я сделал следующее, и это хорошо сформулировано!
public class MyRememberMeService extends PersistentTokenBasedRememberMeServices {
public MyRememberMeService(String key, UserDetailsService userDetailsService, PersistentTokenRepository tokenRepository) {
super(key, userDetailsService, tokenRepository);
}
@Override
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
String rememberMeCookie = extractRememberMeCookie(request);
if (rememberMeCookie == null || rememberMeCookie.length() == 0) {
if (logger.isDebugEnabled()) {
logger.debug("Logout of user "
+ (authentication == null ? "Unknown" : authentication.getName()));
}
cancelCookie(request, response);
} else {
super.logout(request, response, authentication);
}
}
}