问题描述
我使用 spring 安全,我配置 .rememberMe();但是登录后关闭浏览器重新打开页面,页面已经注销了。我打开 cookie 并看到 cookie 记住我内容是空的,过期是我不知道的那一天。如何让记住我正常工作? the cookie when logged
the cookie after close browse and re-open page
我的配置方法:
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/css/**","/js/**","/lib/**","/img/**","/bootstrap/**","/plugins/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().cors();// ajax
http.authorizeRequests().antMatchers("/my-account","/cart","/checkout").authenticated();
http.authorizeRequests().anyRequest().permitAll()
.and()
.formLogin().loginPage("/login").usernameParameter("email")
.and()
.oauth2Login()
.loginPage("/login")
.userInfoEndpoint().userService(oAuth2UserService)
. and().successHandler(customLoginSuccessHandler)
.and()
.logout().permitAll()
.and()
.rememberMe();
}
@Override
@Bean
protected UserDetailsService userDetailsService() {
return new UserDetailsServiceImp();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setPasswordEncoder(passwordEncoder());
authenticationProvider.setUserDetailsService(userDetailsService());
return authenticationProvider;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)